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

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: Remove a blank line 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') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_ios.mm
diff --git a/base/sys_info_mac.cc b/base/sys_info_ios.mm
similarity index 50%
copy from base/sys_info_mac.cc
copy to base/sys_info_ios.mm
index d8210a299932571fd0d41042918daf38e06577e3..48c7bd944841b1f215e44c0cff71a02c1dff54c4 100644
--- a/base/sys_info_mac.cc
+++ b/base/sys_info_ios.mm
@@ -1,41 +1,52 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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"
-#include <ApplicationServices/ApplicationServices.h>
-#include <CoreServices/CoreServices.h>
-#include <mach/mach_host.h>
-#include <mach/mach_init.h>
+#import <UIKit/UIKit.h>
+#include <mach/mach.h>
#include "base/logging.h"
-#include "base/stringprintf.h"
+#include "base/mac/scoped_nsautorelease_pool.h"
+#include "base/sys_string_conversions.h"
namespace base {
// static
std::string SysInfo::OperatingSystemName() {
- return "Mac OS X";
+ base::mac::ScopedNSAutoreleasePool pool;
+ // Examples of returned value: 'iPhone OS' on iPad 5.1.1
+ // and iPhone 5.1.1.
+ return SysNSStringToUTF8([[UIDevice currentDevice] systemName]);
}
// static
std::string SysInfo::OperatingSystemVersion() {
- int32 major, minor, bugfix;
- OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- return base::StringPrintf("%d.%d.%d", major, minor, bugfix);
+ base::mac::ScopedNSAutoreleasePool pool;
+ return SysNSStringToUTF8([[UIDevice currentDevice] systemVersion]);
}
// static
void SysInfo::OperatingSystemVersionNumbers(int32* major_version,
int32* minor_version,
int32* bugfix_version) {
- Gestalt(gestaltSystemVersionMajor,
- reinterpret_cast<SInt32*>(major_version));
- Gestalt(gestaltSystemVersionMinor,
- reinterpret_cast<SInt32*>(minor_version));
- Gestalt(gestaltSystemVersionBugFix,
- reinterpret_cast<SInt32*>(bugfix_version));
+ base::mac::ScopedNSAutoreleasePool pool;
+ NSString* version = [[UIDevice currentDevice] systemVersion];
+ NSArray* version_info = [version componentsSeparatedByString:@"."];
+ NSUInteger length = [version_info count];
+
+ *major_version = [[version_info objectAtIndex:0] intValue];
+
+ if (length >= 2)
+ *minor_version = [[version_info objectAtIndex:1] intValue];
+ else
+ *minor_version = 0;
+
+ if (length >= 3)
+ *bugfix_version = [[version_info objectAtIndex:2] intValue];
+ else
+ *bugfix_version = 0;
}
// static
@@ -46,12 +57,11 @@ int64 SysInfo::AmountOfPhysicalMemory() {
HOST_BASIC_INFO,
reinterpret_cast<host_info_t>(&hostinfo),
&count);
- DCHECK_EQ(HOST_BASIC_INFO_COUNT, count);
if (result != KERN_SUCCESS) {
NOTREACHED();
return 0;
}
-
+ DCHECK_EQ(HOST_BASIC_INFO_COUNT, count);
return static_cast<int64>(hostinfo.max_mem);
}
« no previous file with comments | « base/base.gypi ('k') | base/sys_info_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698