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

Side by Side Diff: base/sys_info_ios.mm

Issue 10704123: Implement SysInfo for iOS (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address review comments Created 8 years, 5 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/sys_info.h"
6
7 #import <UIKit/UIKit.h>
8 #include <mach/mach.h>
9
10 #include "base/logging.h"
11 #include "base/mac/scoped_nsautorelease_pool.h"
12 #include "base/sys_string_conversions.h"
13
14 namespace base {
15
16 // static
17 std::string SysInfo::OperatingSystemName() {
18 base::mac::ScopedNSAutoreleasePool pool;
19 return SysNSStringToUTF8([[UIDevice currentDevice] systemName]);
Mark Mentovai 2012/07/10 16:10:04 I think we should understand what this will return
Chen Yu 2012/07/10 17:07:30 Examples added for ipad and iphone. On 2012/07/10
20 }
21
22 // static
23 std::string SysInfo::OperatingSystemVersion() {
24 base::mac::ScopedNSAutoreleasePool pool;
25 return SysNSStringToUTF8([[UIDevice currentDevice] systemVersion]);
26 }
27
28 // static
29 void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
30 int32* minor_version,
31 int32* bugfix_version) {
32 base::mac::ScopedNSAutoreleasePool pool;
33 NSString* version = [[UIDevice currentDevice] systemVersion];
34 NSArray* versionInfo = [version componentsSeparatedByString:@"."];
Mark Mentovai 2012/07/10 16:10:04 Use this_style naming.
Chen Yu 2012/07/10 17:07:30 Done.
35 NSUInteger length = [versionInfo count];
36
37 *major_version = [[versionInfo objectAtIndex:0] intValue];
38
39 if (length >= 2)
40 *minor_version = [[versionInfo objectAtIndex:1] intValue];
41 else
42 *minor_version = 0;
43
44 if (length >= 3)
45 *bugfix_version = [[versionInfo objectAtIndex:2] intValue];
46 else
47 *bugfix_version = 0;
48 }
49
50 // static
51 int64 SysInfo::AmountOfPhysicalMemory() {
52 struct host_basic_info hostinfo;
53 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
54 int result = host_info(mach_host_self(),
55 HOST_BASIC_INFO,
56 reinterpret_cast<host_info_t>(&hostinfo),
57 &count);
58
59 if (count != HOST_BASIC_INFO_COUNT) {
Mark Mentovai 2012/07/10 16:10:04 I believe I asked you to check result before you c
Chen Yu 2012/07/10 17:07:30 Sorry, I misread your comment; I thought you were
60 NOTREACHED();
61 return 0;
62 }
63
64 if (result != KERN_SUCCESS) {
65 NOTREACHED();
66 return 0;
67 }
68
69 return static_cast<int64>(hostinfo.max_mem);
70 }
71
72 } // namespace base
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/sys_info_mac.cc » ('j') | base/sys_info_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698