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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gypi ('k') | base/sys_info_mac.cc » ('j') | base/sys_info_mac.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« 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