diff options
author | dimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 20:31:10 +0000 |
---|---|---|
committer | dimich@google.com <dimich@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-10 20:31:10 +0000 |
commit | 8711df994152f2dc72dd7f45da8779d73fe1e558 (patch) | |
tree | 7ec65344af0c5ee1792cb0a50cee17d9327a6721 /webkit | |
parent | 61d74983f154e4b6d3e8501b212be6b27de3c500 (diff) | |
download | chromium_src-8711df994152f2dc72dd7f45da8779d73fe1e558.zip chromium_src-8711df994152f2dc72dd7f45da8779d73fe1e558.tar.gz chromium_src-8711df994152f2dc72dd7f45da8779d73fe1e558.tar.bz2 |
Make OSX TestShell able to run workers, using a new test_worker.dylib which is basically a webkit+v8+helpers to simulate separate process with worker v8 threads. This is similar way we do on Win32.
Review URL: http://codereview.chromium.org/66043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13537 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/test_shell/test_shell.gyp | 29 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webworker_helper.cc | 27 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webworker_helper.h | 6 |
3 files changed, 53 insertions, 9 deletions
diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp index 95a35e9..e723c0e 100644 --- a/webkit/tools/test_shell/test_shell.gyp +++ b/webkit/tools/test_shell/test_shell.gyp @@ -464,5 +464,34 @@ }, ], }], + # Need to do the same for Win and Linux. We build a separate dylib/dll/so + # so V8 can have a second set of global variables and run workers. + # Normally, workers run in a separate process. + ['OS=="mac"', { + 'targets': [ + { + 'target_name': 'test_worker', + 'type': 'shared_library', + 'xcode_settings': { + 'EXPORTED_SYMBOLS_FILE': '../../../chrome/test/worker/test_worker.exp', + }, + 'dependencies': [ + '../../../base/base.gyp:base', + '../../../base/base.gyp:base_gfx', + '../../../net/net.gyp:net', + '../../../skia/skia.gyp:skia', + '../../../testing/gtest.gyp:gtest', + '../../../third_party/npapi/npapi.gyp:npapi', + '../../webkit.gyp:glue', + '../../webkit.gyp:webkit', + ], + 'sources': [ + '../../../chrome/test/worker/test_webworker.cc', + '../../../chrome/test/worker/test_worker_main.cc', + '../../../chrome/worker/worker_webkitclient_impl.cc', + ], + }, + ], + }], ], } diff --git a/webkit/tools/test_shell/test_webworker_helper.cc b/webkit/tools/test_shell/test_webworker_helper.cc index c365a2b..6445f98 100644 --- a/webkit/tools/test_shell/test_webworker_helper.cc +++ b/webkit/tools/test_shell/test_webworker_helper.cc @@ -11,13 +11,16 @@ #include "webkit/tools/test_shell/test_webworker_helper.h" +#if defined(OS_MACOSX) +#include <dlfcn.h> +#endif + #include "base/logging.h" #include "base/file_util.h" #include "base/path_service.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "webkit/glue/webworkerclient.h" - WebWorker* TestWebWorkerHelper::CreateWebWorker(WebWorkerClient* client) { TestWebWorkerHelper* loader = new TestWebWorkerHelper(); return loader->CreateWebWorker_(client, loader); @@ -43,28 +46,38 @@ void TestWebWorkerHelper::DispatchToMainThread(WTF::MainThreadFunction* func, return WTF::callOnMainThread(func, context); } -bool TestWebWorkerHelper::Load() { -#if defined(OS_WIN) +void TestWebWorkerHelper::Load() { FilePath path; PathService::Get(base::DIR_EXE, &path); + +#if defined(OS_WIN) path = path.AppendASCII("test_worker.dll"); module_ = LoadLibrary(path.value().c_str()); if (module_ == 0) - return false; + return; CreateWebWorker_ = reinterpret_cast<CreateWebWorkerFunc> (GetProcAddress(module_, "CreateWebWorker")); if (!CreateWebWorker_) { FreeLibrary(module_); module_ = 0; - return false; } +#elif defined(OS_MACOSX) + path = path.AppendASCII("test_worker.dylib"); - return true; + module_ = dlopen(path.value().c_str(), RTLD_NOW | RTLD_LOCAL); + if (!module_) + return; + + CreateWebWorker_ = reinterpret_cast<CreateWebWorkerFunc> + (dlsym(module_, "CreateWebWorker")); + if (!CreateWebWorker_) { + dlclose(module_); + module_ = 0; + } #else NOTIMPLEMENTED(); - return false; #endif } diff --git a/webkit/tools/test_shell/test_webworker_helper.h b/webkit/tools/test_shell/test_webworker_helper.h index 0e6c2b0..6012c95 100644 --- a/webkit/tools/test_shell/test_webworker_helper.h +++ b/webkit/tools/test_shell/test_webworker_helper.h @@ -37,13 +37,15 @@ class TestWebWorkerHelper { virtual void Unload(); private: - bool Load(); + void Load(); static void UnloadHelper(void* param); #if defined(OS_WIN) // TODO(port): Remove ifdefs when we have portable replacement for HMODULE. HMODULE module_; -#endif // defined(OS_WIN) +#elif defined(OS_MACOSX) + void* module_; +#endif CreateWebWorkerFunc CreateWebWorker_; |