Index: base/sys_info_ios.mm |
diff --git a/base/sys_info_ios.mm b/base/sys_info_ios.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8ecb613c2b7c72cd538562e5550f44908fbbb9c0 |
--- /dev/null |
+++ b/base/sys_info_ios.mm |
@@ -0,0 +1,72 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/sys_info.h" |
+ |
+#import <UIKit/UIKit.h> |
+#include <mach/mach.h> |
+ |
+#include "base/logging.h" |
+#include "base/mac/scoped_nsautorelease_pool.h" |
+#include "base/sys_string_conversions.h" |
+ |
+namespace base { |
+ |
+// static |
+std::string SysInfo::OperatingSystemName() { |
+ base::mac::ScopedNSAutoreleasePool pool; |
+ 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
|
+} |
+ |
+// static |
+std::string SysInfo::OperatingSystemVersion() { |
+ base::mac::ScopedNSAutoreleasePool pool; |
+ return SysNSStringToUTF8([[UIDevice currentDevice] systemVersion]); |
+} |
+ |
+// static |
+void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
+ int32* minor_version, |
+ int32* bugfix_version) { |
+ base::mac::ScopedNSAutoreleasePool pool; |
+ NSString* version = [[UIDevice currentDevice] systemVersion]; |
+ 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.
|
+ NSUInteger length = [versionInfo count]; |
+ |
+ *major_version = [[versionInfo objectAtIndex:0] intValue]; |
+ |
+ if (length >= 2) |
+ *minor_version = [[versionInfo objectAtIndex:1] intValue]; |
+ else |
+ *minor_version = 0; |
+ |
+ if (length >= 3) |
+ *bugfix_version = [[versionInfo objectAtIndex:2] intValue]; |
+ else |
+ *bugfix_version = 0; |
+} |
+ |
+// static |
+int64 SysInfo::AmountOfPhysicalMemory() { |
+ struct host_basic_info hostinfo; |
+ mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; |
+ int result = host_info(mach_host_self(), |
+ HOST_BASIC_INFO, |
+ reinterpret_cast<host_info_t>(&hostinfo), |
+ &count); |
+ |
+ 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
|
+ NOTREACHED(); |
+ return 0; |
+ } |
+ |
+ if (result != KERN_SUCCESS) { |
+ NOTREACHED(); |
+ return 0; |
+ } |
+ |
+ return static_cast<int64>(hostinfo.max_mem); |
+} |
+ |
+} // namespace base |