summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/renderer_main_platform_delegate_mac.mm
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 04:56:21 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 04:56:21 +0000
commite5fd10f6814759585a44c4f29353dd36269b4b06 (patch)
tree2e6a8cf4d614258839346c481295fe4f507abb27 /chrome/renderer/renderer_main_platform_delegate_mac.mm
parent0dbb1ebc5db4d16057884de523d8af80eaf017db (diff)
downloadchromium_src-e5fd10f6814759585a44c4f29353dd36269b4b06.zip
chromium_src-e5fd10f6814759585a44c4f29353dd36269b4b06.tar.gz
chromium_src-e5fd10f6814759585a44c4f29353dd36269b4b06.tar.bz2
Temporary fix for the Cocoa-in-renderer problem.
Review URL: http://codereview.chromium.org/27108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/renderer_main_platform_delegate_mac.mm')
-rw-r--r--chrome/renderer/renderer_main_platform_delegate_mac.mm29
1 files changed, 27 insertions, 2 deletions
diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.mm b/chrome/renderer/renderer_main_platform_delegate_mac.mm
index 388305d..e1a6d41 100644
--- a/chrome/renderer/renderer_main_platform_delegate_mac.mm
+++ b/chrome/renderer/renderer_main_platform_delegate_mac.mm
@@ -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 @@ void RendererMainPlatformDelegate::PlatformInitialize() {
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]) {
+ 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 @@ bool RendererMainPlatformDelegate::EnableSandbox() {
// 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 @@ bool RendererMainPlatformDelegate::EnableSandbox() {
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);