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::selectAppChacheID(long long app_cache_id) { | |
74 if (app_cache_host_) { | |
kinuko
2013/12/20 05:29:39
app_cache_host_ could become stale as it's owned b
horo
2013/12/20 07:31:42
Done.
| |
75 app_cache_host_->backend()->SelectCacheForSharedWorker( | |
76 app_cache_host_->host_id(), | |
77 app_cache_id); | |
78 } | |
79 } | |
80 | |
62 blink::WebNotificationPresenter* | 81 blink::WebNotificationPresenter* |
63 WebSharedWorkerClientProxy::notificationPresenter() { | 82 WebSharedWorkerClientProxy::notificationPresenter() { |
64 // TODO(johnnyg): Notifications are not yet hooked up to workers. | 83 // TODO(johnnyg): Notifications are not yet hooked up to workers. |
65 // Coming soon. | 84 // Coming soon. |
66 NOTREACHED(); | 85 NOTREACHED(); |
67 return NULL; | 86 return NULL; |
68 } | 87 } |
69 | 88 |
70 WebApplicationCacheHost* WebSharedWorkerClientProxy::createApplicationCacheHost( | 89 WebApplicationCacheHost* WebSharedWorkerClientProxy::createApplicationCacheHost( |
71 blink::WebApplicationCacheHostClient* client) { | 90 blink::WebApplicationCacheHostClient* client) { |
kinuko
2013/12/20 05:29:39
DCHECK(!app_cache_host_) ?
horo
2013/12/20 07:31:42
Done.
| |
72 WorkerWebApplicationCacheHostImpl* host = | 91 app_cache_host_ = |
73 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), | 92 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), |
74 client); | 93 client); |
75 // Remember the id of the instance we create so we have access to that | 94 // Remember the id of the instance we create so we have access to that |
76 // value when creating nested dedicated workers in createWorker. | 95 // value when creating nested dedicated workers in createWorker. |
77 appcache_host_id_ = host->host_id(); | 96 appcache_host_id_ = app_cache_host_->host_id(); |
78 return host; | 97 return app_cache_host_; |
79 } | 98 } |
80 | 99 |
81 blink::WebWorkerPermissionClientProxy* | 100 blink::WebWorkerPermissionClientProxy* |
82 WebSharedWorkerClientProxy::createWorkerPermissionClientProxy( | 101 WebSharedWorkerClientProxy::createWorkerPermissionClientProxy( |
83 const blink::WebSecurityOrigin& origin) { | 102 const blink::WebSecurityOrigin& origin) { |
84 return new SharedWorkerPermissionClientProxy( | 103 return new SharedWorkerPermissionClientProxy( |
85 GURL(origin.toString()), origin.isUnique(), route_id_, | 104 GURL(origin.toString()), origin.isUnique(), route_id_, |
86 ChildThread::current()->thread_safe_sender()); | 105 ChildThread::current()->thread_safe_sender()); |
87 } | 106 } |
88 | 107 |
(...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 | 143 // 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. | 144 // will exit the message loop and subsequent ones won't be executed. |
126 base::MessageLoop::current()->PostDelayedTask( | 145 base::MessageLoop::current()->PostDelayedTask( |
127 FROM_HERE, | 146 FROM_HERE, |
128 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, | 147 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, |
129 weak_factory_.GetWeakPtr()), | 148 weak_factory_.GetWeakPtr()), |
130 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); | 149 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); |
131 } | 150 } |
132 | 151 |
133 } // namespace content | 152 } // namespace content |
OLD | NEW |