Index: chrome/renderer/renderer_main_platform_delegate_mac.mm |
=================================================================== |
--- chrome/renderer/renderer_main_platform_delegate_mac.mm (revision 10214) |
+++ chrome/renderer/renderer_main_platform_delegate_mac.mm (working copy) |
@@ -8,6 +8,7 @@ |
#import <Foundation/Foundation.h> |
#import <ApplicationServices/ApplicationServices.h> |
+#import <Cocoa/Cocoa.h> |
extern "C" { |
#include <sandbox.h> |
} |
@@ -41,6 +42,30 @@ |
kCGBitmapByteOrder32Host); |
CGColorSpaceRelease(rgb_colorspace); |
CGContextRelease(tmp); |
+ |
+#if 0 |
+ |
+ // Note: by default, Cocoa is NOT thread safe. Use of NSThreads |
+ // tells Cocoa to be MT-aware and create and use locks. The |
+ // renderer process only uses Cocoa from the single renderer thread, |
+ // so we don't need to tell Cocoa we are using threads (even though, |
+ // oddly, we are using Cocoa from the non-main thread.) |
+ // The current limit of renderer processes is 20. Brett states that |
+ // (despite comments to the contrary) when two tabs are using the |
+ // same renderer, we do NOT create a 2nd renderer thread in that |
+ // process. Thus, we don't need to MT-aware Cocoa. |
+ // (Code and comments left here in case that changes.) |
+ if (![NSThread isMultiThreaded]) { |
Mark Mentovai
2009/02/25 14:19:39
FYI, base::InitThreading() from platform_thread_ma
|
+ NSString *string = @""; |
+ [NSThread detachNewThreadSelector:@selector(length) |
+ toTarget:string |
+ withObject:nil]; |
+ } |
+#endif |
+ |
+ // Initialize Cocoa. Without this call, drawing of native UI |
+ // elements (e.g. buttons) in WebKit will explode. |
+ [NSApplication sharedApplication]; |
} |
void RendererMainPlatformDelegate::PlatformUninitialize() { |
@@ -64,7 +89,7 @@ |
// For the renderer, we give it a custom sandbox to lock down as tight as |
// possible, but still be able to draw. If we're not a renderer process, it |
// usually means we're a unittest, so we use a pure compute sandbox instead. |
- |
+ |
const char *sandbox_profile = kSBXProfilePureComputation; |
uint64_t sandbox_flags = SANDBOX_NAMED; |
@@ -80,7 +105,7 @@ |
sandbox_profile = [sandbox_profile_path fileSystemRepresentation]; |
sandbox_flags = SANDBOX_NAMED_EXTERNAL; |
} |
- |
+ |
char* error_buff = NULL; |
int error = sandbox_init(sandbox_profile, sandbox_flags, |
&error_buff); |