Index: content/renderer/shared_worker/embedded_shared_worker_stub.cc |
diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.cc b/content/renderer/shared_worker/embedded_shared_worker_stub.cc |
index aa3452961fcb45034e71543e4854312a29b21c90..d041478980ea6155d79a8f5db2d95503de2e2247 100644 |
--- a/content/renderer/shared_worker/embedded_shared_worker_stub.cc |
+++ b/content/renderer/shared_worker/embedded_shared_worker_stub.cc |
@@ -5,6 +5,8 @@ |
#include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
#include "base/message_loop/message_loop_proxy.h" |
+#include "content/child/appcache/appcache_dispatcher.h" |
+#include "content/child/appcache/web_application_cache_host_impl.h" |
#include "content/child/scoped_child_process_reference.h" |
#include "content/child/shared_worker_devtools_agent.h" |
#include "content/child/webmessageportchannel_impl.h" |
@@ -16,6 +18,39 @@ |
namespace content { |
+namespace { |
+ |
+class SharedWorkerWebApplicationCacheHostImpl |
+ : public WebApplicationCacheHostImpl { |
+ public: |
+ SharedWorkerWebApplicationCacheHostImpl( |
+ blink::WebApplicationCacheHostClient* client) |
+ : WebApplicationCacheHostImpl(client, |
+ RenderThreadImpl::current() |
+ ->appcache_dispatcher() |
+ ->backend_proxy()) {} |
+ |
+ // Main resource loading is different for workers. The main resource is |
+ // loaded by the worker using WorkerScriptLoader. |
+ // These overrides are stubbed out. |
+ virtual void willStartMainResourceRequest( |
+ blink::WebURLRequest&, |
+ const blink::WebApplicationCacheHost*) {} |
+ virtual void didReceiveResponseForMainResource(const blink::WebURLResponse&) { |
+ } |
+ virtual void didReceiveDataForMainResource(const char* data, int len) {} |
+ virtual void didFinishLoadingMainResource(bool success) {} |
+ |
+ // Cache selection is also different for workers. We know at construction |
+ // time what cache to select and do so then. |
+ // These overrides are stubbed out. |
+ virtual void selectCacheWithoutManifest() {} |
+ virtual bool selectCacheWithManifest(const blink::WebURL& manifestURL) { |
+ return true; |
+ } |
+}; |
+} |
+ |
EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( |
const GURL& url, |
const base::string16& name, |
@@ -89,8 +124,13 @@ void EmbeddedSharedWorkerStub::workerContextDestroyed() { |
Shutdown(); |
} |
-void EmbeddedSharedWorkerStub::selectAppCacheID(long long) { |
- // TODO(horo): implement this. |
+void EmbeddedSharedWorkerStub::selectAppCacheID(long long app_cache_id) { |
+ if (app_cache_host_) { |
+ // app_cache_host_ could become stale as it's owned by blink's |
+ // DocumentLoader. This method is assumed to be called while it's valid. |
+ app_cache_host_->backend()->SelectCacheForSharedWorker( |
+ app_cache_host_->host_id(), app_cache_id); |
+ } |
} |
blink::WebNotificationPresenter* |
@@ -101,10 +141,10 @@ EmbeddedSharedWorkerStub::notificationPresenter() { |
} |
blink::WebApplicationCacheHost* |
- EmbeddedSharedWorkerStub::createApplicationCacheHost( |
- blink::WebApplicationCacheHostClient*) { |
- // TODO(horo): implement this. |
- return NULL; |
+EmbeddedSharedWorkerStub::createApplicationCacheHost( |
+ blink::WebApplicationCacheHostClient* client) { |
+ app_cache_host_ = new SharedWorkerWebApplicationCacheHostImpl(client); |
+ return app_cache_host_; |
} |
blink::WebWorkerPermissionClientProxy* |