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

Side by Side Diff: base/ios/ios_util.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: Fixes 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
« no previous file with comments | « base/ios/ios_util.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/ios/ios_util.h"
6
7 #include "base/sys_info.h"
8
9 namespace {
10 // Return a 3 elements array containing the major, minor and bug fix version of
11 // the OS.
12 const int32* OSVersionAsArray() {
13 static int32 digits[3];
Mark Mentovai 2012/10/05 15:03:51 For a single-use function whose return value is st
qsr 2012/10/05 15:33:16 Done.
14 base::SysInfo::OperatingSystemVersionNumbers(
15 &digits[0], &digits[1], &digits[2]);
16 return digits;
17 }
18 }
Mark Mentovai 2012/10/05 15:03:51 } // namespace
qsr 2012/10/05 15:33:16 Done.
19
20 namespace base {
21 namespace ios {
22
23 bool IsRunningOnIOS5OrLater() {
24 return IsRunningOnOrLater(5, 0, 0);
25 }
26
27 bool IsRunningOnIOS6OrLater() {
28 return IsRunningOnOrLater(6, 0, 0);
29 }
30
31 bool IsRunningOnOrLater(int32 major, int32 minor, int32 bug_fix) {
32 static const int32* current_version = OSVersionAsArray();
33 int32 version[3] = { major, minor, bug_fix };
Mark Mentovai 2012/10/05 15:03:51 [3] not necessary.
qsr 2012/10/05 15:33:16 Done.
34 for (int i = 0; i < 3; i++) {
Mark Mentovai 2012/10/05 15:03:51 Use arraysize instead of 3.
qsr 2012/10/05 15:33:16 Done.
35 if (current_version[i] != version[i])
36 return current_version[i] > version[i];
37 }
38 return true;
39 }
40
41 } // namespace ios
42 } // namespace base
OLDNEW
« no previous file with comments | « base/ios/ios_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698