diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-27 18:37:08 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-27 18:37:08 +0000 |
commit | c5a272dbd00c74dffe922523811a4ecbcd7f882b (patch) | |
tree | 90528ee8bec3657a531a2f5095aff97f5f0a3f18 /chrome/worker | |
parent | 445028be1162ed994286addce0b27d0e6239382d (diff) | |
download | chromium_src-c5a272dbd00c74dffe922523811a4ecbcd7f882b.zip chromium_src-c5a272dbd00c74dffe922523811a4ecbcd7f882b.tar.gz chromium_src-c5a272dbd00c74dffe922523811a4ecbcd7f882b.tar.bz2 |
Add Worker support for FileSystem API.
(corresponds to https://bugs.webkit.org/show_bug.cgi?id=45808)
No support for shared workers yet.
BUG=32277
TEST=none; layout tests will be added later.
Review URL: http://codereview.chromium.org/3394003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker')
-rw-r--r-- | chrome/worker/websharedworker_stub.cc | 3 | ||||
-rw-r--r-- | chrome/worker/websharedworker_stub.h | 4 | ||||
-rw-r--r-- | chrome/worker/webworker_stub.cc | 5 | ||||
-rw-r--r-- | chrome/worker/webworker_stub.h | 3 | ||||
-rw-r--r-- | chrome/worker/webworker_stub_base.h | 5 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.cc | 13 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.h | 5 | ||||
-rw-r--r-- | chrome/worker/worker_thread.cc | 4 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.cc | 7 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.h | 4 |
10 files changed, 49 insertions, 4 deletions
diff --git a/chrome/worker/websharedworker_stub.cc b/chrome/worker/websharedworker_stub.cc index 3ddef8d..61ffb31 100644 --- a/chrome/worker/websharedworker_stub.cc +++ b/chrome/worker/websharedworker_stub.cc @@ -4,6 +4,8 @@ #include "chrome/worker/websharedworker_stub.h" +#include "chrome/common/child_thread.h" +#include "chrome/common/file_system/file_system_dispatcher.h" #include "chrome/common/webmessageportchannel_impl.h" #include "chrome/common/worker_messages.h" #include "third_party/WebKit/WebKit/chromium/public/WebSharedWorker.h" @@ -46,6 +48,7 @@ void WebSharedWorkerStub::OnStartWorkerContext( impl_->startWorkerContext(url, name_, user_agent, source_code, 0); started_ = true; + url_ = url; // Process any pending connections. for (PendingConnectInfoList::const_iterator iter = pending_connects_.begin(); diff --git a/chrome/worker/websharedworker_stub.h b/chrome/worker/websharedworker_stub.h index e346bda..157dadb 100644 --- a/chrome/worker/websharedworker_stub.h +++ b/chrome/worker/websharedworker_stub.h @@ -25,10 +25,11 @@ class WebSharedWorkerStub : public WebWorkerStubBase { virtual void OnMessageReceived(const IPC::Message& message); virtual void OnChannelError(); + virtual const GURL& url() const { return url_; } + private: virtual ~WebSharedWorkerStub(); - // Invoked when the WebWorkerClientProxy is shutting down. void OnConnect(int sent_message_port_id, int routing_id); void OnStartWorkerContext( const GURL& url, const string16& user_agent, const string16& source_code); @@ -37,6 +38,7 @@ class WebSharedWorkerStub : public WebWorkerStubBase { WebKit::WebSharedWorker* impl_; string16 name_; bool started_; + GURL url_; typedef std::pair<int, int> PendingConnectInfo; typedef std::vector<PendingConnectInfo> PendingConnectInfoList; diff --git a/chrome/worker/webworker_stub.cc b/chrome/worker/webworker_stub.cc index 89cc384..78d980e 100644 --- a/chrome/worker/webworker_stub.cc +++ b/chrome/worker/webworker_stub.cc @@ -5,7 +5,9 @@ #include "chrome/worker/webworker_stub.h" #include "base/command_line.h" +#include "chrome/common/child_thread.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/file_system/file_system_dispatcher.h" #include "chrome/common/webmessageportchannel_impl.h" #include "chrome/common/worker_messages.h" #include "chrome/worker/nativewebworker_impl.h" @@ -35,7 +37,8 @@ static bool UrlIsNativeWorker(const GURL& url) { WebWorkerStub::WebWorkerStub(const GURL& url, int route_id, const WorkerAppCacheInitInfo& appcache_init_info) - : WebWorkerStubBase(route_id, appcache_init_info) { + : WebWorkerStubBase(route_id, appcache_init_info), + url_(url) { if (UrlIsNativeWorker(url)) { // Launch a native worker. impl_ = NativeWebWorkerImpl::create(client()); diff --git a/chrome/worker/webworker_stub.h b/chrome/worker/webworker_stub.h index 4731588..584abce 100644 --- a/chrome/worker/webworker_stub.h +++ b/chrome/worker/webworker_stub.h @@ -25,6 +25,8 @@ class WebWorkerStub : public WebWorkerStubBase { virtual void OnMessageReceived(const IPC::Message& message); virtual void OnChannelError(); + virtual const GURL& url() const { return url_; } + private: virtual ~WebWorkerStub(); @@ -34,6 +36,7 @@ class WebWorkerStub : public WebWorkerStubBase { const std::vector<int>& new_routing_ids); WebKit::WebWorker* impl_; + GURL url_; DISALLOW_COPY_AND_ASSIGN(WebWorkerStub); }; diff --git a/chrome/worker/webworker_stub_base.h b/chrome/worker/webworker_stub_base.h index d3d44be..2ab2ac7 100644 --- a/chrome/worker/webworker_stub_base.h +++ b/chrome/worker/webworker_stub_base.h @@ -6,6 +6,7 @@ #define CHROME_WORKER_WEBWORKER_STUB_BASE_H_ #pragma once +#include "base/scoped_ptr.h" #include "chrome/worker/webworkerclient_proxy.h" #include "chrome/worker/worker_webapplicationcachehost_impl.h" #include "ipc/ipc_channel.h" @@ -30,6 +31,10 @@ class WebWorkerStubBase : public IPC::Channel::Listener { const WorkerAppCacheInitInfo& appcache_init_info() const { return appcache_init_info_; } + + // Returns the script url of this worker. + virtual const GURL& url() const = 0; + private: int route_id_; WorkerAppCacheInitInfo appcache_init_info_; diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index d591de5..e2ecf5a 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -7,6 +7,8 @@ #include "base/command_line.h" #include "base/message_loop.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/file_system/file_system_dispatcher.h" +#include "chrome/common/file_system/webfilesystem_callback_dispatcher.h" #include "chrome/common/webmessageportchannel_impl.h" #include "chrome/common/worker_messages.h" #include "chrome/renderer/webworker_proxy.h" @@ -14,6 +16,7 @@ #include "chrome/worker/worker_thread.h" #include "chrome/worker/worker_webapplicationcachehost_impl.h" #include "ipc/ipc_logging.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebWorker.h" @@ -121,6 +124,15 @@ WebApplicationCacheHost* WebWorkerClientProxy::createApplicationCacheHost( return host; } +void WebWorkerClientProxy::openFileSystem( + WebKit::WebFileSystem::Type type, + long long size, + WebKit::WebFileSystemCallbacks* callbacks) { + ChildThread::current()->file_system_dispatcher()->OpenFileSystem( + stub_->url().GetOrigin(), static_cast<fileapi::FileSystemType>(type), + size, new WebFileSystemCallbackDispatcher(callbacks)); +} + bool WebWorkerClientProxy::Send(IPC::Message* message) { return WorkerThread::current()->Send(message); } @@ -144,4 +156,3 @@ void WebWorkerClientProxy::EnsureWorkerContextTerminates() { &WebWorkerClientProxy::workerContextDestroyed), kMaxTimeForRunawayWorkerMs); } - diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h index 28a662c..8b19688 100644 --- a/chrome/worker/webworkerclient_proxy.h +++ b/chrome/worker/webworkerclient_proxy.h @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "base/task.h" #include "ipc/ipc_channel.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" #include "third_party/WebKit/WebKit/chromium/public/WebWorkerClient.h" namespace WebKit { @@ -82,6 +83,10 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient { return true; } + virtual void openFileSystem(WebKit::WebFileSystem::Type type, + long long size, + WebKit::WebFileSystemCallbacks* callbacks); + void EnsureWorkerContextTerminates(); private: diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc index c493701..4a8ec52 100644 --- a/chrome/worker/worker_thread.cc +++ b/chrome/worker/worker_thread.cc @@ -55,6 +55,9 @@ WorkerThread::WorkerThread() { WebRuntimeFeatures::enableSockets( !command_line.HasSwitch(switches::kDisableWebSockets)); + + WebRuntimeFeatures::enableFileSystem( + command_line.HasSwitch(switches::kEnableFileSystem)); } WorkerThread::~WorkerThread() { @@ -111,4 +114,3 @@ void WorkerThread::RemoveWorkerStub(WebWorkerStubBase* stub) { void WorkerThread::AddWorkerStub(WebWorkerStubBase* stub) { worker_stubs_.insert(stub); } - diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc index b09ca7b..048bda0 100644 --- a/chrome/worker/worker_webkitclient_impl.cc +++ b/chrome/worker/worker_webkitclient_impl.cc @@ -17,6 +17,7 @@ using WebKit::WebBlobRegistry; using WebKit::WebClipboard; +using WebKit::WebFileSystem; using WebKit::WebKitClient; using WebKit::WebMessagePortChannel; using WebKit::WebMimeRegistry; @@ -35,6 +36,12 @@ WebMimeRegistry* WorkerWebKitClientImpl::mimeRegistry() { return this; } +WebKit::WebFileSystem* WorkerWebKitClientImpl::fileSystem() { + if (!web_file_system_.get()) + web_file_system_.reset(new WebFileSystemImpl()); + return web_file_system_.get(); +} + WebKit::WebFileUtilities* WorkerWebKitClientImpl::fileUtilities() { return &file_utilities_; } diff --git a/chrome/worker/worker_webkitclient_impl.h b/chrome/worker/worker_webkitclient_impl.h index 6488c56..16845ab 100644 --- a/chrome/worker/worker_webkitclient_impl.h +++ b/chrome/worker/worker_webkitclient_impl.h @@ -7,6 +7,7 @@ #pragma once #include "base/scoped_ptr.h" +#include "chrome/common/file_system/webfilesystem_impl.h" #include "third_party/WebKit/WebKit/chromium/public/WebMimeRegistry.h" #include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webkitclient_impl.h" @@ -17,6 +18,7 @@ class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl, // WebKitClient methods: virtual WebKit::WebClipboard* clipboard(); virtual WebKit::WebMimeRegistry* mimeRegistry(); + virtual WebKit::WebFileSystem* fileSystem(); virtual WebKit::WebFileUtilities* fileUtilities(); virtual WebKit::WebSandboxSupport* sandboxSupport(); virtual bool sandboxEnabled(); @@ -72,6 +74,8 @@ class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl, webkit_glue::WebFileUtilitiesImpl file_utilities_; scoped_ptr<WebKit::WebBlobRegistry> blob_registry_; + + scoped_ptr<WebFileSystemImpl> web_file_system_; }; #endif // CHROME_WORKER_WORKER_WEBKITCLIENT_IMPL_H_ |