OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/metrics/previous_session_info.h" | 5 #import "ios/chrome/browser/metrics/previous_session_info.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/scoped_nsobject.h" | |
9 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
10 #include "components/version_info/version_info.h" | 9 #include "components/version_info/version_info.h" |
11 #import "ios/chrome/browser/metrics/previous_session_info_private.h" | 10 #import "ios/chrome/browser/metrics/previous_session_info_private.h" |
12 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
13 namespace { | 16 namespace { |
14 | 17 |
15 // Key in the NSUserDefaults for a string value that stores the version of the | 18 // Key in the NSUserDefaults for a string value that stores the version of the |
16 // last session. | 19 // last session. |
17 NSString* const kLastRanVersion = @"LastRanVersion"; | 20 NSString* const kLastRanVersion = @"LastRanVersion"; |
18 | 21 |
19 } // namespace | 22 } // namespace |
20 | 23 |
21 namespace previous_session_info_constants { | 24 namespace previous_session_info_constants { |
22 NSString* const kDidSeeMemoryWarningShortlyBeforeTerminating = | 25 NSString* const kDidSeeMemoryWarningShortlyBeforeTerminating = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 NSString* lastRanVersion = [defaults stringForKey:kLastRanVersion]; | 59 NSString* lastRanVersion = [defaults stringForKey:kLastRanVersion]; |
57 NSString* currentVersion = | 60 NSString* currentVersion = |
58 base::SysUTF8ToNSString(version_info::GetVersionNumber()); | 61 base::SysUTF8ToNSString(version_info::GetVersionNumber()); |
59 gSharedInstance.isFirstSessionAfterUpgrade = | 62 gSharedInstance.isFirstSessionAfterUpgrade = |
60 ![lastRanVersion isEqualToString:currentVersion]; | 63 ![lastRanVersion isEqualToString:currentVersion]; |
61 } | 64 } |
62 return gSharedInstance; | 65 return gSharedInstance; |
63 } | 66 } |
64 | 67 |
65 + (void)resetSharedInstanceForTesting { | 68 + (void)resetSharedInstanceForTesting { |
66 [gSharedInstance release]; | |
67 gSharedInstance = nil; | 69 gSharedInstance = nil; |
68 } | 70 } |
69 | 71 |
70 - (void)beginRecordingCurrentSession { | 72 - (void)beginRecordingCurrentSession { |
71 if (self.didBeginRecordingCurrentSession) | 73 if (self.didBeginRecordingCurrentSession) |
72 return; | 74 return; |
73 self.didBeginRecordingCurrentSession = YES; | 75 self.didBeginRecordingCurrentSession = YES; |
74 | 76 |
75 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 77 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
76 | 78 |
(...skipping 29 matching lines...) Expand all Loading... |
106 | 108 |
107 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 109 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
108 [defaults | 110 [defaults |
109 removeObjectForKey:previous_session_info_constants:: | 111 removeObjectForKey:previous_session_info_constants:: |
110 kDidSeeMemoryWarningShortlyBeforeTerminating]; | 112 kDidSeeMemoryWarningShortlyBeforeTerminating]; |
111 // Save critical state information for crash detection. | 113 // Save critical state information for crash detection. |
112 [defaults synchronize]; | 114 [defaults synchronize]; |
113 } | 115 } |
114 | 116 |
115 @end | 117 @end |
OLD | NEW |