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..7f11eac2de0952698777109527992b2d1bd79845 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 |
Mark Mentovai
2012/07/10 17:11:27
Thank you!
|
+ // 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,12 @@ int64 SysInfo::AmountOfPhysicalMemory() { |
HOST_BASIC_INFO, |
reinterpret_cast<host_info_t>(&hostinfo), |
&count); |
- DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); |
+ |
Mark Mentovai
2012/07/10 17:11:27
Remove this blank line (so that this function matc
Chen Yu
2012/07/10 17:13:24
Done.
|
if (result != KERN_SUCCESS) { |
NOTREACHED(); |
return 0; |
} |
- |
+ DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); |
return static_cast<int64>(hostinfo.max_mem); |
} |