Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/chrome_browser_application_mac.mm

Issue 2762014: Mac: clang build (Closed)
Patch Set: more Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/chrome_browser_application_mac.h" 5 #import "chrome/browser/chrome_browser_application_mac.h"
6 6
7 #import "base/histogram.h" 7 #import "base/histogram.h"
8 #import "base/logging.h" 8 #import "base/logging.h"
9 #import "base/scoped_nsobject.h" 9 #import "base/scoped_nsobject.h"
10 #import "base/sys_string_conversions.h" 10 #import "base/sys_string_conversions.h"
(...skipping 20 matching lines...) Expand all
31 - (id)chromeInitWithName:(NSString *)aName 31 - (id)chromeInitWithName:(NSString *)aName
32 reason:(NSString *)aReason 32 reason:(NSString *)aReason
33 userInfo:(NSDictionary *)someUserInfo { 33 userInfo:(NSDictionary *)someUserInfo {
34 // Method only called when swizzled. 34 // Method only called when swizzled.
35 DCHECK(_cmd == @selector(initWithName:reason:userInfo:)); 35 DCHECK(_cmd == @selector(initWithName:reason:userInfo:));
36 36
37 // Parts of Cocoa rely on creating and throwing exceptions. These are not 37 // Parts of Cocoa rely on creating and throwing exceptions. These are not
38 // worth bugging-out over. It is very important that there be zero chance that 38 // worth bugging-out over. It is very important that there be zero chance that
39 // any Chromium code is on the stack; these must be created by Apple code and 39 // any Chromium code is on the stack; these must be created by Apple code and
40 // then immediately consumed by Apple code. 40 // then immediately consumed by Apple code.
41 static const NSString* kAcceptableNSExceptionNames[] = { 41 static NSString* kAcceptableNSExceptionNames[] = {
42 // If an object does not support an accessibility attribute, this will 42 // If an object does not support an accessibility attribute, this will
43 // get thrown. 43 // get thrown.
44 NSAccessibilityException, 44 NSAccessibilityException,
45 45
46 nil 46 nil
47 }; 47 };
48 48
49 BOOL found = NO; 49 BOOL found = NO;
50 for (int i = 0; kAcceptableNSExceptionNames[i]; ++i) { 50 for (int i = 0; kAcceptableNSExceptionNames[i]; ++i) {
51 if (aName == kAcceptableNSExceptionNames[i]) { 51 if (aName == kAcceptableNSExceptionNames[i]) {
(...skipping 26 matching lines...) Expand all
78 // interesting to track in aggregate (those relating to distributed 78 // interesting to track in aggregate (those relating to distributed
79 // objects, for instance). 79 // objects, for instance).
80 const size_t kKnownNSExceptionCount = 25; 80 const size_t kKnownNSExceptionCount = 25;
81 81
82 const size_t kUnknownNSException = kKnownNSExceptionCount; 82 const size_t kUnknownNSException = kKnownNSExceptionCount;
83 83
84 size_t BinForException(NSException* exception) { 84 size_t BinForException(NSException* exception) {
85 // A list of common known exceptions. The list position will 85 // A list of common known exceptions. The list position will
86 // determine where they live in the histogram, so never move them 86 // determine where they live in the histogram, so never move them
87 // around, only add to the end. 87 // around, only add to the end.
88 static const NSString* kKnownNSExceptionNames[] = { 88 static NSString* kKnownNSExceptionNames[] = {
89 // ??? 89 // ???
90 NSGenericException, 90 NSGenericException,
91 91
92 // Out-of-range on NSString or NSArray. 92 // Out-of-range on NSString or NSArray.
93 NSRangeException, 93 NSRangeException,
94 94
95 // Invalid arg to method, unrecognized selector. 95 // Invalid arg to method, unrecognized selector.
96 NSInvalidArgumentException, 96 NSInvalidArgumentException,
97 97
98 // malloc() returned null in object creation, I think. 98 // malloc() returned null in object creation, I think.
99 NSMallocException, 99 NSMallocException,
100 100
101 nil 101 nil
102 }; 102 };
103 103
104 // Make sure our array hasn't outgrown our abilities to track it. 104 // Make sure our array hasn't outgrown our abilities to track it.
105 DCHECK_LE(arraysize(kKnownNSExceptionNames), kKnownNSExceptionCount); 105 DCHECK_LE(arraysize(kKnownNSExceptionNames), kKnownNSExceptionCount);
106 106
107 const NSString* name = [exception name]; 107 NSString* name = [exception name];
108 for (int i = 0; kKnownNSExceptionNames[i]; ++i) { 108 for (int i = 0; kKnownNSExceptionNames[i]; ++i) {
109 if (name == kKnownNSExceptionNames[i]) { 109 if (name == kKnownNSExceptionNames[i]) {
110 return i; 110 return i;
111 } 111 }
112 } 112 }
113 return kUnknownNSException; 113 return kUnknownNSException;
114 } 114 }
115 115
116 void RecordExceptionWithUma(NSException* exception) { 116 void RecordExceptionWithUma(NSException* exception) {
117 UMA_HISTOGRAM_ENUMERATION("OSX.NSException", 117 UMA_HISTOGRAM_ENUMERATION("OSX.NSException",
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 } 268 }
269 if (!found) { 269 if (!found) {
270 return NO; 270 return NO;
271 } 271 }
272 } 272 }
273 273
274 // When a Cocoa control is wired to a freed object, we get crashers 274 // When a Cocoa control is wired to a freed object, we get crashers
275 // in the call to |super| with no useful information in the 275 // in the call to |super| with no useful information in the
276 // backtrace. Attempt to add some useful information. 276 // backtrace. Attempt to add some useful information.
277 static const NSString* kActionKey = @"sendaction"; 277 static NSString* kActionKey = @"sendaction";
278 278
279 // If the action is something generic like -commandDispatch:, then 279 // If the action is something generic like -commandDispatch:, then
280 // the tag is essential. 280 // the tag is essential.
281 NSInteger tag = 0; 281 NSInteger tag = 0;
282 if ([sender isKindOfClass:[NSControl class]]) { 282 if ([sender isKindOfClass:[NSControl class]]) {
283 tag = [sender tag]; 283 tag = [sender tag];
284 if (tag == 0 || tag == -1) { 284 if (tag == 0 || tag == -1) {
285 tag = [sender selectedTag]; 285 tag = [sender selectedTag];
286 } 286 }
287 } else if ([sender isKindOfClass:[NSMenuItem class]]) { 287 } else if ([sender isKindOfClass:[NSMenuItem class]]) {
(...skipping 21 matching lines...) Expand all
309 if (!reportingException) { 309 if (!reportingException) {
310 reportingException = YES; 310 reportingException = YES;
311 chrome_browser_application_mac::RecordExceptionWithUma(anException); 311 chrome_browser_application_mac::RecordExceptionWithUma(anException);
312 312
313 // Store some human-readable information in breakpad keys in case 313 // Store some human-readable information in breakpad keys in case
314 // there is a crash. Since breakpad does not provide infinite 314 // there is a crash. Since breakpad does not provide infinite
315 // storage, we track two exceptions. The first exception thrown 315 // storage, we track two exceptions. The first exception thrown
316 // is tracked because it may be the one which caused the system to 316 // is tracked because it may be the one which caused the system to
317 // go off the rails. The last exception thrown is tracked because 317 // go off the rails. The last exception thrown is tracked because
318 // it may be the one most directly associated with the crash. 318 // it may be the one most directly associated with the crash.
319 static const NSString* kFirstExceptionKey = @"firstexception"; 319 static NSString* kFirstExceptionKey = @"firstexception";
320 static BOOL trackedFirstException = NO; 320 static BOOL trackedFirstException = NO;
321 static const NSString* kLastExceptionKey = @"lastexception"; 321 static NSString* kLastExceptionKey = @"lastexception";
322 322
323 // TODO(shess): It would be useful to post some stacktrace info 323 // TODO(shess): It would be useful to post some stacktrace info
324 // from the exception. 324 // from the exception.
325 // 10.6 has -[NSException callStackSymbols] 325 // 10.6 has -[NSException callStackSymbols]
326 // 10.5 has -[NSException callStackReturnAddresses] 326 // 10.5 has -[NSException callStackReturnAddresses]
327 // 10.5 has backtrace_symbols(). 327 // 10.5 has backtrace_symbols().
328 // I've tried to combine the latter two, but got nothing useful. 328 // I've tried to combine the latter two, but got nothing useful.
329 // The addresses are right, though, maybe we could train the crash 329 // The addresses are right, though, maybe we could train the crash
330 // server to decode them for us. 330 // server to decode them for us.
331 331
332 NSString* value = [NSString stringWithFormat:@"%@ reason %@", 332 NSString* value = [NSString stringWithFormat:@"%@ reason %@",
333 [anException name], [anException reason]]; 333 [anException name], [anException reason]];
334 if (!trackedFirstException) { 334 if (!trackedFirstException) {
335 SetCrashKeyValue(kFirstExceptionKey, value); 335 SetCrashKeyValue(kFirstExceptionKey, value);
336 trackedFirstException = YES; 336 trackedFirstException = YES;
337 } else { 337 } else {
338 SetCrashKeyValue(kLastExceptionKey, value); 338 SetCrashKeyValue(kLastExceptionKey, value);
339 } 339 }
340 340
341 reportingException = NO; 341 reportingException = NO;
342 } 342 }
343 343
344 [super reportException:anException]; 344 [super reportException:anException];
345 } 345 }
346 346
347 @end 347 @end
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_text_field_mac.mm ('k') | chrome/browser/cocoa/authorization_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698