michael@0: // Copyright (c) 2012, Google Inc. michael@0: // All rights reserved. michael@0: // michael@0: // Redistribution and use in source and binary forms, with or without michael@0: // modification, are permitted provided that the following conditions are michael@0: // met: michael@0: // michael@0: // * Redistributions of source code must retain the above copyright michael@0: // notice, this list of conditions and the following disclaimer. michael@0: // * Redistributions in binary form must reproduce the above michael@0: // copyright notice, this list of conditions and the following disclaimer michael@0: // in the documentation and/or other materials provided with the michael@0: // distribution. michael@0: // * Neither the name of Google Inc. nor the names of its michael@0: // contributors may be used to endorse or promote products derived from michael@0: // this software without specific prior written permission. michael@0: // michael@0: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT michael@0: // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@0: // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@0: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: michael@0: #ifndef CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_ michael@0: #define CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_ michael@0: michael@0: #import michael@0: michael@0: #import "client/ios/Breakpad.h" michael@0: michael@0: // This class is used to offer a higher level API around BreakpadRef. It michael@0: // configures it, ensures thread-safety, and sends crash reports back to the michael@0: // collecting server. By default, no crash reports are sent, the user must call michael@0: // |setUploadingEnabled:YES| to start the uploading. michael@0: @interface BreakpadController : NSObject { michael@0: @private michael@0: // The dispatch queue that will own the breakpad reference. michael@0: dispatch_queue_t queue_; michael@0: michael@0: // Instance of Breakpad crash reporter. This is owned by the queue, but can michael@0: // be created on the main thread at startup. michael@0: BreakpadRef breakpadRef_; michael@0: michael@0: // The dictionary that contains configuration for breakpad. Modifying it michael@0: // should only happen when the controller is not started. The initial value michael@0: // is the infoDictionary of the bundle of the application. michael@0: NSMutableDictionary* configuration_; michael@0: michael@0: // Whether or not crash reports should be uploaded. michael@0: BOOL enableUploads_; michael@0: michael@0: // Whether the controller has been started on the main thread. This is only michael@0: // used to assert the initialization order is correct. michael@0: BOOL started_; michael@0: michael@0: // The interval to wait between two uploads. Value is 0 if no upload must be michael@0: // done. michael@0: int uploadIntervalInSeconds_; michael@0: } michael@0: michael@0: // Singleton. michael@0: + (BreakpadController*)sharedInstance; michael@0: michael@0: // Update the controller configuration. Merges its old configuration with the michael@0: // new one. Merge is done by replacing the old values by the new values. michael@0: - (void)updateConfiguration:(NSDictionary*)configuration; michael@0: michael@0: // Configure the URL to upload the report to. This must be called at least once michael@0: // if the URL is not in the bundle information. michael@0: - (void)setUploadingURL:(NSString*)url; michael@0: michael@0: // Set the minimal interval between two uploads in seconds. This must be called michael@0: // at least once if the interval is not in the bundle information. A value of 0 michael@0: // will prevent uploads. michael@0: - (void)setUploadInterval:(int)intervalInSeconds; michael@0: michael@0: // Specify a parameter that will be uploaded to the crash server. See michael@0: // |BreakpadAddUploadParameter|. michael@0: - (void)addUploadParameter:(NSString*)value forKey:(NSString*)key; michael@0: michael@0: // Remove a previously-added parameter from the upload parameter set. See michael@0: // |BreakpadRemoveUploadParameter|. michael@0: - (void)removeUploadParameterForKey:(NSString*)key; michael@0: michael@0: // Access the underlying BreakpadRef. This method is asynchronous, and will be michael@0: // executed on the thread owning the BreakpadRef variable. Moreover, if the michael@0: // controller is not started, the block will be called with a NULL parameter. michael@0: - (void)withBreakpadRef:(void(^)(BreakpadRef))callback; michael@0: michael@0: // Starts the BreakpadController by registering crash handlers. If michael@0: // |onCurrentThread| is YES, all setup is done on the current thread, otherwise michael@0: // it is done on a private queue. michael@0: - (void)start:(BOOL)onCurrentThread; michael@0: michael@0: // Unregisters the crash handlers. michael@0: - (void)stop; michael@0: michael@0: // Enables or disables uploading of crash reports, but does not stop the michael@0: // BreakpadController. michael@0: - (void)setUploadingEnabled:(BOOL)enabled; michael@0: michael@0: // Check if there is currently a crash report to upload. michael@0: - (void)hasReportToUpload:(void(^)(BOOL))callback; michael@0: michael@0: @end michael@0: michael@0: #endif // CLIENT_IOS_HANDLER_IOS_BREAKPAD_CONTROLLER_H_