Updating BreakpadController to allow start and stop being nop.

When BreakpadController is already started or stopped, trying to restart it or
restopping it will now be no-op instead of asserting.
Review URL: https://breakpad.appspot.com/505002

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1092 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
qsr@chromium.org 2012-12-17 14:20:13 +00:00
parent 6aab1f92bb
commit bdd7220794

View file

@ -129,6 +129,9 @@ NSString* GetPlatform() {
#pragma mark - #pragma mark -
- (void)start:(BOOL)onCurrentThread { - (void)start:(BOOL)onCurrentThread {
if (started)
return;
started_ = YES;
void(^startBlock)() = ^{ void(^startBlock)() = ^{
assert(!breakpadRef_); assert(!breakpadRef_);
breakpadRef_ = BreakpadCreate(configuration_); breakpadRef_ = BreakpadCreate(configuration_);
@ -136,8 +139,6 @@ NSString* GetPlatform() {
BreakpadAddUploadParameter(breakpadRef_, @"platform", GetPlatform()); BreakpadAddUploadParameter(breakpadRef_, @"platform", GetPlatform());
} }
}; };
NSAssert(!started_, @"Start cannot be called more than once.");
started_ = YES;
if (onCurrentThread) if (onCurrentThread)
startBlock(); startBlock();
else else
@ -145,8 +146,8 @@ NSString* GetPlatform() {
} }
- (void)stop { - (void)stop {
NSAssert(started_, if (!started)
@"The controller must be started before it can be stopped"); return;
started_ = NO; started_ = NO;
dispatch_sync(queue_, ^{ dispatch_sync(queue_, ^{
if (breakpadRef_) { if (breakpadRef_) {