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

Side by Side Diff: base/sys_info_ios.mm

Issue 11031066: Adding utility method to test the version of the OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile issue Created 8 years, 2 months 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 | Annotate | Revision Log
« base/sys_info.h ('K') | « base/sys_info.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "base/sys_info.h" 5 #include "base/sys_info.h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 #include <mach/mach.h> 8 #include <mach/mach.h>
9 #include <sys/sysctl.h> 9 #include <sys/sysctl.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 // static 70 // static
71 std::string SysInfo::CPUModelName() { 71 std::string SysInfo::CPUModelName() {
72 char name[256]; 72 char name[256];
73 size_t len = arraysize(name); 73 size_t len = arraysize(name);
74 if (sysctlbyname("machdep.cpu.brand_string", &name, &len, NULL, 0) == 0) 74 if (sysctlbyname("machdep.cpu.brand_string", &name, &len, NULL, 0) == 0)
75 return name; 75 return name;
76 return std::string(); 76 return std::string();
77 } 77 }
78 78
79 // static
80 bool SysInfo::IsRunningOnIOS5OrLater() {
81 return IsRunningOnOrLater(5, 0, 0);
82 }
83
84 // static
85 bool SysInfo::IsRunningOnIOS6OrLater() {
86 return IsRunningOnOrLater(6, 0, 0);
87 }
88
89 // static
90 bool SysInfo::IsRunningOnOrLater(int major, int minor, int bugFix) {
91 static int32 digits[3] = { 0, 0, 0 };
Mark Mentovai 2012/10/05 12:49:05 You know how I feel about these. I’d prefer to jus
qsr 2012/10/05 14:53:56 Done.
92 if (digits[0] == 0) {
93 OperatingSystemVersionNumbers(&digits[0], &digits[1], &digits[2]);
Mark Mentovai 2012/10/05 12:49:05 mac_util uses uname for its runtime OS version che
qsr 2012/10/05 14:53:56 On iOS, we are calling: [[UIDevice currentDevice]
94 }
95 if (digits[0] < major)
Mark Mentovai 2012/10/05 12:49:05 Seems like this could be written as a loop. Or wou
qsr 2012/10/05 14:53:56 I'll do a loop. Version is working on string. I do
96 return NO;
97 if (digits[0] > major)
98 return YES;
99 // digits[0] == major
100 if (digits[1] < minor)
101 return NO;
102 if (digits[1] > minor)
103 return YES;
104 // digits[1] == minor
105 if (digits[2] < bugFix)
106 return NO;
107 // digits[2] >= bugFix
108 return YES;
109 }
110
79 } // namespace base 111 } // namespace base
OLDNEW
« base/sys_info.h ('K') | « base/sys_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698