| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/sandbox_mac.h" | 5 #include "chrome/common/sandbox_mac.h" |
| 6 | 6 |
| 7 #include "base/debug_util.h" | 7 #include "base/debug_util.h" |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 extern "C" { | 10 extern "C" { |
| 11 #include <sandbox.h> | 11 #include <sandbox.h> |
| 12 } | 12 } |
| 13 #include <sys/param.h> | 13 #include <sys/param.h> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
| 18 #include "base/mac_util.h" | 18 #include "base/mac_util.h" |
| 19 #include "base/rand_util_c.h" | 19 #include "base/rand_util_c.h" |
| 20 #include "base/mac/scoped_cftyperef.h" | 20 #include "base/mac/scoped_cftyperef.h" |
| 21 #include "base/scoped_nsautorelease_pool.h" | 21 #include "base/mac/scoped_nsautorelease_pool.h" |
| 22 #include "base/string16.h" | 22 #include "base/string16.h" |
| 23 #include "base/string_util.h" | 23 #include "base/string_util.h" |
| 24 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
| 25 #include "base/sys_string_conversions.h" | 25 #include "base/sys_string_conversions.h" |
| 26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "unicode/uchar.h" | 28 #include "unicode/uchar.h" |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 | 181 |
| 182 // Warm up System APIs that empirically need to be accessed before the Sandbox | 182 // Warm up System APIs that empirically need to be accessed before the Sandbox |
| 183 // is turned on. | 183 // is turned on. |
| 184 // This method is layed out in blocks, each one containing a separate function | 184 // This method is layed out in blocks, each one containing a separate function |
| 185 // that needs to be warmed up. The OS version on which we found the need to | 185 // that needs to be warmed up. The OS version on which we found the need to |
| 186 // enable the function is also noted. | 186 // enable the function is also noted. |
| 187 // This function is tested on the following OS versions: | 187 // This function is tested on the following OS versions: |
| 188 // 10.5.6, 10.6.0 | 188 // 10.5.6, 10.6.0 |
| 189 void SandboxWarmup() { | 189 void SandboxWarmup() { |
| 190 base::ScopedNSAutoreleasePool scoped_pool; | 190 base::mac::ScopedNSAutoreleasePool scoped_pool; |
| 191 | 191 |
| 192 { // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6 | 192 { // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6 |
| 193 base::mac::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace( | 193 base::mac::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace( |
| 194 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)); | 194 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)); |
| 195 | 195 |
| 196 // Allocate a 1x1 image. | 196 // Allocate a 1x1 image. |
| 197 char data[4]; | 197 char data[4]; |
| 198 base::mac::ScopedCFTypeRef<CGContextRef> context( | 198 base::mac::ScopedCFTypeRef<CGContextRef> context( |
| 199 CGBitmapContextCreate(data, 1, 1, 8, 1 * 4, | 199 CGBitmapContextCreate(data, 1, 1, 8, 1 * 4, |
| 200 rgb_colorspace, | 200 rgb_colorspace, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { | 421 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { |
| 422 PLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " | 422 PLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " |
| 423 << path->value(); | 423 << path->value(); |
| 424 return; | 424 return; |
| 425 } | 425 } |
| 426 | 426 |
| 427 *path = FilePath(canonical_path); | 427 *path = FilePath(canonical_path); |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace sandbox | 430 } // namespace sandbox |
| OLD | NEW |