OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
6 | 6 |
7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "content/child/appcache/appcache_dispatcher.h" |
| 9 #include "content/child/appcache/web_application_cache_host_impl.h" |
8 #include "content/child/scoped_child_process_reference.h" | 10 #include "content/child/scoped_child_process_reference.h" |
9 #include "content/child/shared_worker_devtools_agent.h" | 11 #include "content/child/shared_worker_devtools_agent.h" |
10 #include "content/child/webmessageportchannel_impl.h" | 12 #include "content/child/webmessageportchannel_impl.h" |
11 #include "content/common/worker_messages.h" | 13 #include "content/common/worker_messages.h" |
12 #include "content/renderer/render_thread_impl.h" | 14 #include "content/renderer/render_thread_impl.h" |
13 #include "ipc/ipc_message_macros.h" | 15 #include "ipc/ipc_message_macros.h" |
14 #include "third_party/WebKit/public/web/WebSharedWorker.h" | 16 #include "third_party/WebKit/public/web/WebSharedWorker.h" |
15 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" | 17 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 | 20 |
| 21 namespace { |
| 22 |
| 23 class SharedWorkerWebApplicationCacheHostImpl |
| 24 : public WebApplicationCacheHostImpl { |
| 25 public: |
| 26 SharedWorkerWebApplicationCacheHostImpl( |
| 27 blink::WebApplicationCacheHostClient* client) |
| 28 : WebApplicationCacheHostImpl(client, |
| 29 RenderThreadImpl::current() |
| 30 ->appcache_dispatcher() |
| 31 ->backend_proxy()) {} |
| 32 |
| 33 // Main resource loading is different for workers. The main resource is |
| 34 // loaded by the worker using WorkerScriptLoader. |
| 35 // These overrides are stubbed out. |
| 36 virtual void willStartMainResourceRequest( |
| 37 blink::WebURLRequest&, |
| 38 const blink::WebApplicationCacheHost*) {} |
| 39 virtual void didReceiveResponseForMainResource(const blink::WebURLResponse&) { |
| 40 } |
| 41 virtual void didReceiveDataForMainResource(const char* data, int len) {} |
| 42 virtual void didFinishLoadingMainResource(bool success) {} |
| 43 |
| 44 // Cache selection is also different for workers. We know at construction |
| 45 // time what cache to select and do so then. |
| 46 // These overrides are stubbed out. |
| 47 virtual void selectCacheWithoutManifest() {} |
| 48 virtual bool selectCacheWithManifest(const blink::WebURL& manifestURL) { |
| 49 return true; |
| 50 } |
| 51 }; |
| 52 } |
| 53 |
19 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( | 54 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( |
20 const GURL& url, | 55 const GURL& url, |
21 const base::string16& name, | 56 const base::string16& name, |
22 const base::string16& content_security_policy, | 57 const base::string16& content_security_policy, |
23 blink::WebContentSecurityPolicyType security_policy_type, | 58 blink::WebContentSecurityPolicyType security_policy_type, |
24 int route_id) | 59 int route_id) |
25 : route_id_(route_id), | 60 : route_id_(route_id), |
26 name_(name), | 61 name_(name), |
27 runing_(false), | 62 runing_(false), |
28 url_(url) { | 63 url_(url) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 117 |
83 void EmbeddedSharedWorkerStub::workerContextClosed() { | 118 void EmbeddedSharedWorkerStub::workerContextClosed() { |
84 Send(new WorkerHostMsg_WorkerContextClosed(route_id_)); | 119 Send(new WorkerHostMsg_WorkerContextClosed(route_id_)); |
85 } | 120 } |
86 | 121 |
87 void EmbeddedSharedWorkerStub::workerContextDestroyed() { | 122 void EmbeddedSharedWorkerStub::workerContextDestroyed() { |
88 Send(new WorkerHostMsg_WorkerContextDestroyed(route_id_)); | 123 Send(new WorkerHostMsg_WorkerContextDestroyed(route_id_)); |
89 Shutdown(); | 124 Shutdown(); |
90 } | 125 } |
91 | 126 |
92 void EmbeddedSharedWorkerStub::selectAppCacheID(long long) { | 127 void EmbeddedSharedWorkerStub::selectAppCacheID(long long app_cache_id) { |
93 // TODO(horo): implement this. | 128 if (app_cache_host_) { |
| 129 // app_cache_host_ could become stale as it's owned by blink's |
| 130 // DocumentLoader. This method is assumed to be called while it's valid. |
| 131 app_cache_host_->backend()->SelectCacheForSharedWorker( |
| 132 app_cache_host_->host_id(), app_cache_id); |
| 133 } |
94 } | 134 } |
95 | 135 |
96 blink::WebNotificationPresenter* | 136 blink::WebNotificationPresenter* |
97 EmbeddedSharedWorkerStub::notificationPresenter() { | 137 EmbeddedSharedWorkerStub::notificationPresenter() { |
98 // TODO(horo): delete this method if we have no plan to implement this. | 138 // TODO(horo): delete this method if we have no plan to implement this. |
99 NOTREACHED(); | 139 NOTREACHED(); |
100 return NULL; | 140 return NULL; |
101 } | 141 } |
102 | 142 |
103 blink::WebApplicationCacheHost* | 143 blink::WebApplicationCacheHost* |
104 EmbeddedSharedWorkerStub::createApplicationCacheHost( | 144 EmbeddedSharedWorkerStub::createApplicationCacheHost( |
105 blink::WebApplicationCacheHostClient*) { | 145 blink::WebApplicationCacheHostClient* client) { |
106 // TODO(horo): implement this. | 146 app_cache_host_ = new SharedWorkerWebApplicationCacheHostImpl(client); |
107 return NULL; | 147 return app_cache_host_; |
108 } | 148 } |
109 | 149 |
110 blink::WebWorkerPermissionClientProxy* | 150 blink::WebWorkerPermissionClientProxy* |
111 EmbeddedSharedWorkerStub::createWorkerPermissionClientProxy( | 151 EmbeddedSharedWorkerStub::createWorkerPermissionClientProxy( |
112 const blink::WebSecurityOrigin& origin) { | 152 const blink::WebSecurityOrigin& origin) { |
113 // TODO(horo): implement this. | 153 // TODO(horo): implement this. |
114 return NULL; | 154 return NULL; |
115 } | 155 } |
116 | 156 |
117 void EmbeddedSharedWorkerStub::dispatchDevToolsMessage( | 157 void EmbeddedSharedWorkerStub::dispatchDevToolsMessage( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 pending_channels_.push_back(channel); | 195 pending_channels_.push_back(channel); |
156 } | 196 } |
157 } | 197 } |
158 | 198 |
159 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { | 199 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { |
160 runing_ = false; | 200 runing_ = false; |
161 impl_->terminateWorkerContext(); | 201 impl_->terminateWorkerContext(); |
162 } | 202 } |
163 | 203 |
164 } // namespace content | 204 } // namespace content |
OLD | NEW |