Chromium Code Reviews| 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" | 8 #include "base/mac/foundation_util.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 11 #error "This file requires ARC support." | |
| 12 #endif | |
| 10 | 13 |
| 11 namespace { | 14 namespace { |
| 12 | 15 |
| 13 NSString* const kStartupCrashModulesKey = @"StartupCrashModules"; | 16 NSString* const kStartupCrashModulesKey = @"StartupCrashModules"; |
| 14 NSString* const kModuleFriendlyNameKey = @"ModuleFriendlyName"; | 17 NSString* const kModuleFriendlyNameKey = @"ModuleFriendlyName"; |
| 15 | 18 |
| 16 } // namespace | 19 } // namespace |
| 17 | 20 |
| 18 @interface SafeModeCrashingModulesConfig () { | 21 @interface SafeModeCrashingModulesConfig () { |
|
sdefresne
2017/02/21 14:20:25
nit: move this to @implementation
stkhapugin
2017/02/21 15:47:02
Done.
| |
| 19 base::scoped_nsobject<NSDictionary> _configuration; | 22 NSDictionary* _configuration; |
| 20 } | 23 } |
| 21 @end | 24 @end |
| 22 | 25 |
| 23 @implementation SafeModeCrashingModulesConfig | 26 @implementation SafeModeCrashingModulesConfig |
| 24 | 27 |
| 25 + (SafeModeCrashingModulesConfig*)sharedInstance { | 28 + (SafeModeCrashingModulesConfig*)sharedInstance { |
| 26 static SafeModeCrashingModulesConfig* instance = | 29 static SafeModeCrashingModulesConfig* instance = |
| 27 [[SafeModeCrashingModulesConfig alloc] init]; | 30 [[SafeModeCrashingModulesConfig alloc] init]; |
| 28 return instance; | 31 return instance; |
| 29 } | 32 } |
| 30 | 33 |
| 31 - (instancetype)init { | 34 - (instancetype)init { |
| 32 self = [super init]; | 35 self = [super init]; |
| 33 if (self) { | 36 if (self) { |
| 34 NSString* configPath = | 37 NSString* configPath = |
| 35 [[NSBundle mainBundle] pathForResource:@"SafeModeCrashingModules" | 38 [[NSBundle mainBundle] pathForResource:@"SafeModeCrashingModules" |
| 36 ofType:@"plist"]; | 39 ofType:@"plist"]; |
| 37 _configuration.reset( | 40 _configuration = [[NSDictionary alloc] initWithContentsOfFile:configPath]; |
| 38 [[NSDictionary alloc] initWithContentsOfFile:configPath]); | |
| 39 } | 41 } |
| 40 return self; | 42 return self; |
| 41 } | 43 } |
| 42 | 44 |
| 43 - (NSString*)startupCrashModuleFriendlyName:(NSString*)modulePath { | 45 - (NSString*)startupCrashModuleFriendlyName:(NSString*)modulePath { |
| 44 NSDictionary* modules = base::mac::ObjCCastStrict<NSDictionary>( | 46 NSDictionary* modules = base::mac::ObjCCastStrict<NSDictionary>( |
| 45 [_configuration objectForKey:kStartupCrashModulesKey]); | 47 [_configuration objectForKey:kStartupCrashModulesKey]); |
| 46 NSDictionary* module = | 48 NSDictionary* module = |
| 47 base::mac::ObjCCastStrict<NSDictionary>(modules[modulePath]); | 49 base::mac::ObjCCastStrict<NSDictionary>(modules[modulePath]); |
| 48 return base::mac::ObjCCast<NSString>(module[kModuleFriendlyNameKey]); | 50 return base::mac::ObjCCast<NSString>(module[kModuleFriendlyNameKey]); |
| 49 } | 51 } |
| 50 | 52 |
| 51 @end | 53 @end |
| OLD | NEW |