1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/client/ios/BreakpadController.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,113 @@ 1.4 +// Copyright (c) 2012, Google Inc. 1.5 +// All rights reserved. 1.6 +// 1.7 +// Redistribution and use in source and binary forms, with or without 1.8 +// modification, are permitted provided that the following conditions are 1.9 +// met: 1.10 +// 1.11 +// * Redistributions of source code must retain the above copyright 1.12 +// notice, this list of conditions and the following disclaimer. 1.13 +// * Redistributions in binary form must reproduce the above 1.14 +// copyright notice, this list of conditions and the following disclaimer 1.15 +// in the documentation and/or other materials provided with the 1.16 +// distribution. 1.17 +// * Neither the name of Google Inc. nor the names of its 1.18 +// contributors may be used to endorse or promote products derived from 1.19 +// this software without specific prior written permission. 1.20 +// 1.21 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.22 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.23 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.24 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.25 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.26 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.27 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.28 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.29 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.30 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.31 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.32 + 1.33 +#ifndef CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_ 1.34 +#define CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_ 1.35 + 1.36 +#import <Foundation/Foundation.h> 1.37 + 1.38 +#import "client/ios/Breakpad.h" 1.39 + 1.40 +// This class is used to offer a higher level API around BreakpadRef. It 1.41 +// configures it, ensures thread-safety, and sends crash reports back to the 1.42 +// collecting server. By default, no crash reports are sent, the user must call 1.43 +// |setUploadingEnabled:YES| to start the uploading. 1.44 +@interface BreakpadController : NSObject { 1.45 + @private 1.46 + // The dispatch queue that will own the breakpad reference. 1.47 + dispatch_queue_t queue_; 1.48 + 1.49 + // Instance of Breakpad crash reporter. This is owned by the queue, but can 1.50 + // be created on the main thread at startup. 1.51 + BreakpadRef breakpadRef_; 1.52 + 1.53 + // The dictionary that contains configuration for breakpad. Modifying it 1.54 + // should only happen when the controller is not started. The initial value 1.55 + // is the infoDictionary of the bundle of the application. 1.56 + NSMutableDictionary* configuration_; 1.57 + 1.58 + // Whether or not crash reports should be uploaded. 1.59 + BOOL enableUploads_; 1.60 + 1.61 + // Whether the controller has been started on the main thread. This is only 1.62 + // used to assert the initialization order is correct. 1.63 + BOOL started_; 1.64 + 1.65 + // The interval to wait between two uploads. Value is 0 if no upload must be 1.66 + // done. 1.67 + int uploadIntervalInSeconds_; 1.68 +} 1.69 + 1.70 +// Singleton. 1.71 ++ (BreakpadController*)sharedInstance; 1.72 + 1.73 +// Update the controller configuration. Merges its old configuration with the 1.74 +// new one. Merge is done by replacing the old values by the new values. 1.75 +- (void)updateConfiguration:(NSDictionary*)configuration; 1.76 + 1.77 +// Configure the URL to upload the report to. This must be called at least once 1.78 +// if the URL is not in the bundle information. 1.79 +- (void)setUploadingURL:(NSString*)url; 1.80 + 1.81 +// Set the minimal interval between two uploads in seconds. This must be called 1.82 +// at least once if the interval is not in the bundle information. A value of 0 1.83 +// will prevent uploads. 1.84 +- (void)setUploadInterval:(int)intervalInSeconds; 1.85 + 1.86 +// Specify a parameter that will be uploaded to the crash server. See 1.87 +// |BreakpadAddUploadParameter|. 1.88 +- (void)addUploadParameter:(NSString*)value forKey:(NSString*)key; 1.89 + 1.90 +// Remove a previously-added parameter from the upload parameter set. See 1.91 +// |BreakpadRemoveUploadParameter|. 1.92 +- (void)removeUploadParameterForKey:(NSString*)key; 1.93 + 1.94 +// Access the underlying BreakpadRef. This method is asynchronous, and will be 1.95 +// executed on the thread owning the BreakpadRef variable. Moreover, if the 1.96 +// controller is not started, the block will be called with a NULL parameter. 1.97 +- (void)withBreakpadRef:(void(^)(BreakpadRef))callback; 1.98 + 1.99 +// Starts the BreakpadController by registering crash handlers. If 1.100 +// |onCurrentThread| is YES, all setup is done on the current thread, otherwise 1.101 +// it is done on a private queue. 1.102 +- (void)start:(BOOL)onCurrentThread; 1.103 + 1.104 +// Unregisters the crash handlers. 1.105 +- (void)stop; 1.106 + 1.107 +// Enables or disables uploading of crash reports, but does not stop the 1.108 +// BreakpadController. 1.109 +- (void)setUploadingEnabled:(BOOL)enabled; 1.110 + 1.111 +// Check if there is currently a crash report to upload. 1.112 +- (void)hasReportToUpload:(void(^)(BOOL))callback; 1.113 + 1.114 +@end 1.115 + 1.116 +#endif // CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_