summaryrefslogtreecommitdiffstats
path: root/chrome/worker/webworkerclient_proxy.cc
diff options
context:
space:
mode:
authorsehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-29 00:30:51 +0000
committersehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-29 00:30:51 +0000
commit07506b507533d46e7ef826819ec9c5cbca5035aa (patch)
tree6cfc1f745d2703904174adec70eb60fe1d089861 /chrome/worker/webworkerclient_proxy.cc
parent241415acc358cbfb1054c2f4f8510ecbe6fe8c29 (diff)
downloadchromium_src-07506b507533d46e7ef826819ec9c5cbca5035aa.zip
chromium_src-07506b507533d46e7ef826819ec9c5cbca5035aa.tar.gz
chromium_src-07506b507533d46e7ef826819ec9c5cbca5035aa.tar.bz2
Added stub native web worker support, including build support in preparation
for integrating the native client build. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker/webworkerclient_proxy.cc')
-rw-r--r--chrome/worker/webworkerclient_proxy.cc29
1 files changed, 27 insertions, 2 deletions
diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc
index 8a0a6f1..85a410b 100644
--- a/chrome/worker/webworkerclient_proxy.cc
+++ b/chrome/worker/webworkerclient_proxy.cc
@@ -11,6 +11,7 @@
#include "chrome/common/worker_messages.h"
#include "chrome/renderer/webworker_proxy.h"
#include "chrome/worker/worker_thread.h"
+#include "chrome/worker/nativewebworker_impl.h"
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebWorker.h"
@@ -39,10 +40,34 @@ class KillProcessTask : public Task {
}
+static bool UrlIsNativeWorker(const GURL& url) {
+ // If the renderer was not passed the switch to enable native workers,
+ // then the URL should be treated as a JavaScript worker.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableNativeWebWorkers)) {
+ return false;
+ }
+ // Based on the suffix, decide whether the url should be considered
+ // a NativeWebWorker (for .nexe) or a WebWorker (for anything else).
+ const std::string kNativeSuffix(".nexe");
+ std::string worker_url = url.path();
+ // Compute the start index of the suffix.
+ std::string::size_type suffix_index =
+ worker_url.length() - kNativeSuffix.length();
+ std::string::size_type pos = worker_url.find(kNativeSuffix, suffix_index);
+ return (suffix_index == pos);
+}
+
WebWorkerClientProxy::WebWorkerClientProxy(const GURL& url, int route_id)
: url_(url),
- route_id_(route_id),
- ALLOW_THIS_IN_INITIALIZER_LIST(impl_(WebWorker::create(this))) {
+ route_id_(route_id) {
+ if (UrlIsNativeWorker(url)) {
+ // Launch a native worker.
+ impl_ = NativeWebWorkerImpl::create(this);
+ } else {
+ // Launch a JavaScript worker.
+ impl_ = WebWorker::create(this);
+ }
WorkerThread::current()->AddRoute(route_id_, this);
ChildProcess::current()->AddRefProcess();
}