Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Side by Side Diff: content/worker/websharedworkerclient_proxy.cc

Issue 115713004: Move the worker script loading code to the worker process (phase:2/5) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move IPC_ENUM_TRAITS(blink::WebContentSecurityPolicyType) to content_param_traits_macros.h. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/worker/websharedworkerclient_proxy.h ('k') | content/worker/worker_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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. This method is assumed to be called while it's valid.
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 19 matching lines...) Expand all
108 // page. It's ok to post several of theese, because the first executed task 130 // page. It's ok to post several of theese, because the first executed task
109 // will exit the message loop and subsequent ones won't be executed. 131 // will exit the message loop and subsequent ones won't be executed.
110 base::MessageLoop::current()->PostDelayedTask( 132 base::MessageLoop::current()->PostDelayedTask(
111 FROM_HERE, 133 FROM_HERE,
112 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, 134 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed,
113 weak_factory_.GetWeakPtr()), 135 weak_factory_.GetWeakPtr()),
114 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); 136 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds));
115 } 137 }
116 138
117 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « content/worker/websharedworkerclient_proxy.h ('k') | content/worker/worker_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698