Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/worker/websharedworkerclient_proxy.h" | 5 #include "content/worker/websharedworkerclient_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/child/webmessageportchannel_impl.h" | 10 #include "content/child/webmessageportchannel_impl.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 // How long to wait for worker to finish after it's been told to terminate. | 36 // How long to wait for worker to finish after it's been told to terminate. |
| 37 #define kMaxTimeForRunawayWorkerSeconds 3 | 37 #define kMaxTimeForRunawayWorkerSeconds 3 |
| 38 | 38 |
| 39 WebSharedWorkerClientProxy::WebSharedWorkerClientProxy( | 39 WebSharedWorkerClientProxy::WebSharedWorkerClientProxy( |
| 40 int route_id, WebSharedWorkerStub* stub) | 40 int route_id, WebSharedWorkerStub* stub) |
| 41 : route_id_(route_id), | 41 : route_id_(route_id), |
| 42 appcache_host_id_(0), | 42 appcache_host_id_(0), |
| 43 stub_(stub), | 43 stub_(stub), |
| 44 weak_factory_(this), | 44 weak_factory_(this), |
| 45 devtools_agent_(NULL) { | 45 devtools_agent_(NULL), |
| 46 app_cache_host_(NULL) { | |
| 46 } | 47 } |
| 47 | 48 |
| 48 WebSharedWorkerClientProxy::~WebSharedWorkerClientProxy() { | 49 WebSharedWorkerClientProxy::~WebSharedWorkerClientProxy() { |
| 49 } | 50 } |
| 50 | 51 |
| 51 void WebSharedWorkerClientProxy::workerContextClosed() { | 52 void WebSharedWorkerClientProxy::workerContextClosed() { |
| 52 Send(new WorkerHostMsg_WorkerContextClosed(route_id_)); | 53 Send(new WorkerHostMsg_WorkerContextClosed(route_id_)); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void WebSharedWorkerClientProxy::workerContextDestroyed() { | 56 void WebSharedWorkerClientProxy::workerContextDestroyed() { |
| 56 Send(new WorkerHostMsg_WorkerContextDestroyed(route_id_)); | 57 Send(new WorkerHostMsg_WorkerContextDestroyed(route_id_)); |
| 57 // Tell the stub that the worker has shutdown - frees this object. | 58 // Tell the stub that the worker has shutdown - frees this object. |
| 58 if (stub_) | 59 if (stub_) |
| 59 stub_->Shutdown(); | 60 stub_->Shutdown(); |
| 60 } | 61 } |
| 61 | 62 |
| 63 void WebSharedWorkerClientProxy::workerScriptLoaded() { | |
| 64 if (stub_) | |
| 65 stub_->WorkerScriptLoaded(); | |
| 66 } | |
| 67 | |
| 68 void WebSharedWorkerClientProxy::workerScriptLoadFailed() { | |
| 69 if (stub_) | |
| 70 stub_->WorkerScriptLoadFailed(); | |
| 71 } | |
| 72 | |
| 73 void WebSharedWorkerClientProxy::selectAppCacheID(long long app_cache_id) { | |
| 74 if (app_cache_host_) { | |
| 75 // app_cache_host_ could become stale as it's owned by blink's | |
| 76 // DocumentLoader. So we have to call selectAppCacheID while it's valid. | |
|
kinuko
2013/12/20 08:23:21
nit: 'So we have to call selectAppCacheID' -> 'Thi
horo
2013/12/20 08:48:15
Done.
It will be called from WebSharedWorkerImpl i
| |
| 77 app_cache_host_->backend()->SelectCacheForSharedWorker( | |
| 78 app_cache_host_->host_id(), | |
| 79 app_cache_id); | |
| 80 } | |
| 81 } | |
| 82 | |
| 62 blink::WebNotificationPresenter* | 83 blink::WebNotificationPresenter* |
| 63 WebSharedWorkerClientProxy::notificationPresenter() { | 84 WebSharedWorkerClientProxy::notificationPresenter() { |
| 64 // TODO(johnnyg): Notifications are not yet hooked up to workers. | 85 // TODO(johnnyg): Notifications are not yet hooked up to workers. |
| 65 // Coming soon. | 86 // Coming soon. |
| 66 NOTREACHED(); | 87 NOTREACHED(); |
| 67 return NULL; | 88 return NULL; |
| 68 } | 89 } |
| 69 | 90 |
| 70 WebApplicationCacheHost* WebSharedWorkerClientProxy::createApplicationCacheHost( | 91 WebApplicationCacheHost* WebSharedWorkerClientProxy::createApplicationCacheHost( |
| 71 blink::WebApplicationCacheHostClient* client) { | 92 blink::WebApplicationCacheHostClient* client) { |
| 72 WorkerWebApplicationCacheHostImpl* host = | 93 DCHECK(!app_cache_host_); |
| 94 app_cache_host_ = | |
| 73 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), | 95 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), |
| 74 client); | 96 client); |
| 75 // Remember the id of the instance we create so we have access to that | 97 // Remember the id of the instance we create so we have access to that |
| 76 // value when creating nested dedicated workers in createWorker. | 98 // value when creating nested dedicated workers in createWorker. |
| 77 appcache_host_id_ = host->host_id(); | 99 appcache_host_id_ = app_cache_host_->host_id(); |
| 78 return host; | 100 return app_cache_host_; |
| 79 } | 101 } |
| 80 | 102 |
| 81 blink::WebWorkerPermissionClientProxy* | 103 blink::WebWorkerPermissionClientProxy* |
| 82 WebSharedWorkerClientProxy::createWorkerPermissionClientProxy( | 104 WebSharedWorkerClientProxy::createWorkerPermissionClientProxy( |
| 83 const blink::WebSecurityOrigin& origin) { | 105 const blink::WebSecurityOrigin& origin) { |
| 84 return new SharedWorkerPermissionClientProxy( | 106 return new SharedWorkerPermissionClientProxy( |
| 85 GURL(origin.toString()), origin.isUnique(), route_id_, | 107 GURL(origin.toString()), origin.isUnique(), route_id_, |
| 86 ChildThread::current()->thread_safe_sender()); | 108 ChildThread::current()->thread_safe_sender()); |
| 87 } | 109 } |
| 88 | 110 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 // page. It's ok to post several of theese, because the first executed task | 146 // page. It's ok to post several of theese, because the first executed task |
| 125 // will exit the message loop and subsequent ones won't be executed. | 147 // will exit the message loop and subsequent ones won't be executed. |
| 126 base::MessageLoop::current()->PostDelayedTask( | 148 base::MessageLoop::current()->PostDelayedTask( |
| 127 FROM_HERE, | 149 FROM_HERE, |
| 128 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, | 150 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, |
| 129 weak_factory_.GetWeakPtr()), | 151 weak_factory_.GetWeakPtr()), |
| 130 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); | 152 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); |
| 131 } | 153 } |
| 132 | 154 |
| 133 } // namespace content | 155 } // namespace content |
| OLD | NEW |