Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "components/crash/core/common/crash_keys.h" | 9 #include "components/crash/core/common/crash_keys.h" |
| 10 #include "ios/chrome/app/startup/ios_chrome_main.h" | 10 #include "ios/chrome/app/startup/ios_chrome_main.h" |
| 11 #include "ios/chrome/browser/crash_report/breakpad_helper.h" | 11 #include "ios/chrome/browser/crash_report/breakpad_helper.h" |
| 12 #include "ios/chrome/browser/crash_report/crash_keys.h" | 12 #include "ios/chrome/browser/crash_report/crash_keys.h" |
| 13 #include "ios/chrome/common/channel_info.h" | 13 #include "ios/chrome/common/channel_info.h" |
| 14 | 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 16 #error "This file requires ARC support." | |
| 17 #endif | |
| 18 | |
| 15 namespace { | 19 namespace { |
| 16 | 20 |
| 17 NSString* const kUIApplicationDelegateInfoKey = @"UIApplicationDelegate"; | 21 NSString* const kUIApplicationDelegateInfoKey = @"UIApplicationDelegate"; |
| 18 | 22 |
| 19 void StartCrashController() { | 23 void StartCrashController() { |
| 20 std::string channel_string = GetChannelString(); | 24 std::string channel_string = GetChannelString(); |
| 21 | 25 |
| 22 RegisterChromeIOSCrashKeys(); | 26 RegisterChromeIOSCrashKeys(); |
| 23 base::debug::SetCrashKeyValue(crash_keys::kChannel, channel_string); | 27 base::debug::SetCrashKeyValue(crash_keys::kChannel, channel_string); |
| 24 breakpad_helper::Start(channel_string); | 28 breakpad_helper::Start(channel_string); |
| 25 } | 29 } |
| 26 | 30 |
| 27 } // namespace | 31 } // namespace |
| 28 | 32 |
| 29 int main(int argc, char* argv[]) { | 33 int main(int argc, char* argv[]) { |
| 30 IOSChromeMain::InitStartTime(); | 34 IOSChromeMain::InitStartTime(); |
| 31 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; | |
| 32 | 35 |
| 33 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; | 36 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; |
| 34 | 37 |
| 35 // Set NSUserDefaults keys to force pseudo-RTL if needed. | 38 // Set NSUserDefaults keys to force pseudo-RTL if needed. |
| 36 if ([standardDefaults boolForKey:@"EnablePseudoRTL"]) { | 39 if ([standardDefaults boolForKey:@"EnablePseudoRTL"]) { |
| 37 NSDictionary* pseudoDict = @{ @"YES" : @"AppleTextDirection" }; | 40 NSDictionary* pseudoDict = @{ @"YES" : @"AppleTextDirection" }; |
| 38 [standardDefaults registerDefaults:pseudoDict]; | 41 [standardDefaults registerDefaults:pseudoDict]; |
| 39 } | 42 } |
| 40 | 43 |
| 41 // Create this here since it's needed to start the crash handler. | 44 // Create this here since it's needed to start the crash handler. |
| 42 base::AtExitManager at_exit; | 45 base::AtExitManager at_exit; |
| 43 | 46 |
| 44 // The Crash Controller is started here even if the user opted out since we | 47 // The Crash Controller is started here even if the user opted out since we |
| 45 // don't have yet preferences. Later on it is stopped if the user opted out. | 48 // don't have yet preferences. Later on it is stopped if the user opted out. |
| 46 // In any case reports are not sent if the user opted out. | 49 // In any case reports are not sent if the user opted out. |
| 47 StartCrashController(); | 50 StartCrashController(); |
| 48 | 51 |
| 49 // Always ignore SIGPIPE. We check the return value of write(). | 52 // Always ignore SIGPIPE. We check the return value of write(). |
| 50 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); | 53 CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN)); |
| 51 | 54 |
| 52 // Purging the pool to prevent autorelease objects created by the previous | |
| 53 // calls to live forever. | |
|
rohitrao (ping after 24h)
2017/05/18 20:50:34
We added this autorelease pool for a specific reas
stkhapugin
2017/05/30 14:04:06
This should be replaced with @autoreleasepool in a
liaoyuke
2017/06/14 00:02:23
Have uploaded this parent CL: https://chromium-rev
| |
| 54 [pool release]; | |
| 55 pool = [[NSAutoreleasePool alloc] init]; | |
| 56 | 55 |
| 57 // Part of code that requires us to specify which UIApplication delegate class | 56 // Part of code that requires us to specify which UIApplication delegate class |
| 58 // to use by adding "UIApplicationDelegate" key to Info.plist file. | 57 // to use by adding "UIApplicationDelegate" key to Info.plist file. |
| 59 NSString* delegateClassName = [[NSBundle mainBundle] | 58 NSString* delegateClassName = [[NSBundle mainBundle] |
| 60 objectForInfoDictionaryKey:kUIApplicationDelegateInfoKey]; | 59 objectForInfoDictionaryKey:kUIApplicationDelegateInfoKey]; |
| 61 CHECK(delegateClassName); | 60 CHECK(delegateClassName); |
| 62 | 61 |
| 63 int retVal = UIApplicationMain(argc, argv, nil, delegateClassName); | 62 int retVal = UIApplicationMain(argc, argv, nil, delegateClassName); |
| 64 [pool release]; | |
| 65 return retVal; | 63 return retVal; |
| 66 } | 64 } |
| OLD | NEW |