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

Side by Side Diff: chrome/common/sandbox_mac.mm

Issue 3855001: Move scoped_cftyperef from base to base/mac, use the new namespace, and name ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/scoped_cftyperef.h" 20 #include "base/mac/scoped_cftyperef.h"
21 #include "base/scoped_nsautorelease_pool.h" 21 #include "base/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 {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::ScopedNSAutoreleasePool scoped_pool;
191 191
192 { // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6 192 { // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6
193 scoped_cftyperef<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 scoped_cftyperef<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,
201 kCGImageAlphaPremultipliedFirst | 201 kCGImageAlphaPremultipliedFirst |
202 kCGBitmapByteOrder32Host)); 202 kCGBitmapByteOrder32Host));
203 203
204 // Load in the color profiles we'll need (as a side effect). 204 // Load in the color profiles we'll need (as a side effect).
205 (void) mac_util::GetSRGBColorSpace(); 205 (void) mac_util::GetSRGBColorSpace();
206 (void) mac_util::GetSystemColorSpace(); 206 (void) mac_util::GetSystemColorSpace();
207 207
208 // CGColorSpaceCreateSystemDefaultCMYK - 10.6 208 // CGColorSpaceCreateSystemDefaultCMYK - 10.6
209 scoped_cftyperef<CGColorSpaceRef> cmyk_colorspace( 209 base::mac::ScopedCFTypeRef<CGColorSpaceRef> cmyk_colorspace(
210 CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK)); 210 CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK));
211 } 211 }
212 212
213 { // [-NSColor colorUsingColorSpaceName] - 10.5.6 213 { // [-NSColor colorUsingColorSpaceName] - 10.5.6
214 NSColor* color = [NSColor controlTextColor]; 214 NSColor* color = [NSColor controlTextColor];
215 [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; 215 [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
216 } 216 }
217 217
218 { // localtime() - 10.5.6 218 { // localtime() - 10.5.6
219 time_t tv = {0}; 219 time_t tv = {0};
220 localtime(&tv); 220 localtime(&tv);
221 } 221 }
222 222
223 { // Gestalt() tries to read /System/Library/CoreServices/SystemVersion.plist 223 { // Gestalt() tries to read /System/Library/CoreServices/SystemVersion.plist
224 // on 10.5.6 224 // on 10.5.6
225 int32 tmp; 225 int32 tmp;
226 base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp); 226 base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp);
227 } 227 }
228 228
229 { // CGImageSourceGetStatus() - 10.6 229 { // CGImageSourceGetStatus() - 10.6
230 // Create a png with just enough data to get everything warmed up... 230 // Create a png with just enough data to get everything warmed up...
231 char png_header[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; 231 char png_header[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
232 NSData* data = [NSData dataWithBytes:png_header 232 NSData* data = [NSData dataWithBytes:png_header
233 length:arraysize(png_header)]; 233 length:arraysize(png_header)];
234 scoped_cftyperef<CGImageSourceRef> img( 234 base::mac::ScopedCFTypeRef<CGImageSourceRef> img(
235 CGImageSourceCreateWithData((CFDataRef)data, 235 CGImageSourceCreateWithData((CFDataRef)data,
236 NULL)); 236 NULL));
237 CGImageSourceGetStatus(img); 237 CGImageSourceGetStatus(img);
238 } 238 }
239 239
240 { // Native Client access to /dev/random. 240 { // Native Client access to /dev/random.
241 GetUrandomFD(); 241 GetUrandomFD();
242 } 242 }
243 } 243 }
244 244
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « chrome/common/mach_message_source_mac.cc ('k') | chrome/common/sandbox_mac_fontloading_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698