OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/chrome/app/safe_mode_crashing_modules_config.h" | 5 #import "ios/chrome/app/safe_mode_crashing_modules_config.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/foundation_util.h" | |
9 #import "base/mac/scoped_nsobject.h" | |
8 | 10 |
9 namespace { | 11 namespace { |
10 | 12 |
11 NSString* const kStartupCrashModulesKey = @"StartupCrashModules"; | 13 NSString* const kStartupCrashModulesKey = @"StartupCrashModules"; |
12 NSString* const kModuleFriendlyNameKey = @"ModuleFriendlyName"; | 14 NSString* const kModuleFriendlyNameKey = @"ModuleFriendlyName"; |
13 | 15 |
14 } // namespace | 16 } // namespace |
15 | 17 |
18 @interface SafeModeCrashingModulesConfig () { | |
19 base::scoped_nsobject<NSDictionary> _configuration; | |
20 } | |
21 @end | |
22 | |
16 @implementation SafeModeCrashingModulesConfig | 23 @implementation SafeModeCrashingModulesConfig |
17 | 24 |
18 + (SafeModeCrashingModulesConfig*)sharedInstance { | 25 + (SafeModeCrashingModulesConfig*)sharedInstance { |
19 static SafeModeCrashingModulesConfig* instance = | 26 static SafeModeCrashingModulesConfig* instance = |
20 [[SafeModeCrashingModulesConfig alloc] init]; | 27 [[SafeModeCrashingModulesConfig alloc] init]; |
21 return instance; | 28 return instance; |
22 } | 29 } |
23 | 30 |
24 - (instancetype)init { | 31 - (instancetype)init { |
25 self = [super initWithAppId:nil version:nil plist:@"CrashingModules.plist"]; | 32 self = [super init]; |
26 if (self) { | 33 if (self) { |
27 self.stopsUpdateChecksOnAppTermination = YES; | 34 NSString* configPath = |
35 [[NSBundle mainBundle] pathForResource:@"CrashingModules" | |
36 ofType:@"plist"]; | |
37 _configuration.reset( | |
38 [[NSDictionary alloc] initWithContentsOfFile:configPath]); | |
28 } | 39 } |
29 return self; | 40 return self; |
30 } | 41 } |
31 | 42 |
32 - (NSString*)startupCrashModuleFriendlyName:(NSString*)modulePath { | 43 - (NSString*)startupCrashModuleFriendlyName:(NSString*)modulePath { |
33 NSDictionary* configData = [self dictionaryFromConfig]; | 44 NSDictionary* modules = base::mac::ObjCCastStrict<NSDictionary>( |
rohitrao (ping after 24h)
2016/07/15 17:23:19
Does this method also get called during startup?
pkl (ping after 24h if needed)
2016/07/15 20:33:18
This method is currently called from Safe Mode Vie
| |
34 NSDictionary* modules = [configData objectForKey:kStartupCrashModulesKey]; | 45 [_configuration objectForKey:kStartupCrashModulesKey]); |
35 if (modules) { | 46 NSDictionary* module = |
36 DCHECK([modules isKindOfClass:[NSDictionary class]]); | 47 base::mac::ObjCCastStrict<NSDictionary>(modules[modulePath]); |
37 NSDictionary* module = modules[modulePath]; | 48 return base::mac::ObjCCast<NSString>(module[kModuleFriendlyNameKey]); |
38 if (module) { | |
39 DCHECK([module isKindOfClass:[NSDictionary class]]); | |
40 return module[kModuleFriendlyNameKey]; | |
41 } | |
42 } | |
43 return nil; | |
44 } | 49 } |
45 | 50 |
46 @end | 51 @end |
OLD | NEW |