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

Side by Side Diff: ios/chrome/browser/install_time_util.mm

Issue 1544743002: Switch to standard integer types in ios/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « ios/chrome/browser/install_time_util.h ('k') | ios/chrome/browser/installation_notifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ios/chrome/browser/install_time_util.h" 5 #include "ios/chrome/browser/install_time_util.h"
6 6
7 #include <Foundation/Foundation.h> 7 #include <Foundation/Foundation.h>
8 #include <stdint.h>
8 9
9 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
10 11
11 namespace { 12 namespace {
12 13
13 NSString* const kInstallationTimeKey = @"omaha.InstallationTime"; 14 NSString* const kInstallationTimeKey = @"omaha.InstallationTime";
14 15
15 // Returns the installation time of the application: this is the time the 16 // Returns the installation time of the application: this is the time the
16 // application was first installed, not the time the last version was installed. 17 // application was first installed, not the time the last version was installed.
17 // If the installation time is unknown, returns a base::Time corresponding to 18 // If the installation time is unknown, returns a base::Time corresponding to
18 // |kUnknownInstallDate|. 19 // |kUnknownInstallDate|.
19 // To be noted: this value is reset if the application is uninstalled. 20 // To be noted: this value is reset if the application is uninstalled.
20 base::Time GetNSUserDefaultsInstallationTime() { 21 base::Time GetNSUserDefaultsInstallationTime() {
21 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 22 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
22 CFAbsoluteTime time = [defaults doubleForKey:kInstallationTimeKey]; 23 CFAbsoluteTime time = [defaults doubleForKey:kInstallationTimeKey];
23 if (time == 0.0) 24 if (time == 0.0)
24 return base::Time(); 25 return base::Time();
25 return base::Time::FromCFAbsoluteTime(time); 26 return base::Time::FromCFAbsoluteTime(time);
26 } 27 }
27 28
28 } // namespace 29 } // namespace
29 30
30 namespace install_time_util { 31 namespace install_time_util {
31 32
32 // 2 is used because 0 is a magic value for Time, and 1 was the pre-M29 value 33 // 2 is used because 0 is a magic value for Time, and 1 was the pre-M29 value
33 // which was migrated to a specific date (crbug.com/270124). 34 // which was migrated to a specific date (crbug.com/270124).
34 const int64 kUnknownInstallDate = 2; 35 const int64_t kUnknownInstallDate = 2;
35 36
36 base::Time ComputeInstallationTime(bool is_first_run) { 37 base::Time ComputeInstallationTime(bool is_first_run) {
37 return ComputeInstallationTimeInternal(is_first_run, 38 return ComputeInstallationTimeInternal(is_first_run,
38 GetNSUserDefaultsInstallationTime()); 39 GetNSUserDefaultsInstallationTime());
39 } 40 }
40 41
41 base::Time ComputeInstallationTimeInternal( 42 base::Time ComputeInstallationTimeInternal(
42 bool is_first_run, 43 bool is_first_run,
43 base::Time ns_user_defaults_install_time) { 44 base::Time ns_user_defaults_install_time) {
44 if (is_first_run) 45 if (is_first_run)
45 return base::Time::Now(); 46 return base::Time::Now();
46 47
47 if (ns_user_defaults_install_time.is_null()) 48 if (ns_user_defaults_install_time.is_null())
48 return base::Time::FromTimeT(kUnknownInstallDate); 49 return base::Time::FromTimeT(kUnknownInstallDate);
49 50
50 return ns_user_defaults_install_time; 51 return ns_user_defaults_install_time;
51 } 52 }
52 53
53 } // namespace install_time_util 54 } // namespace install_time_util
OLDNEW
« no previous file with comments | « ios/chrome/browser/install_time_util.h ('k') | ios/chrome/browser/installation_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698