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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 140743012: Start EmbeddedWorker during registration - take 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up existing registration case Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/service_worker/embedded_worker_registry.h" 8 #include "content/browser/service_worker/embedded_worker_registry.h"
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 OnSendMessageToBrowser) 81 OnSendMessageToBrowser)
82 IPC_MESSAGE_UNHANDLED(handled = false) 82 IPC_MESSAGE_UNHANDLED(handled = false)
83 IPC_END_MESSAGE_MAP() 83 IPC_END_MESSAGE_MAP()
84 84
85 return handled; 85 return handled;
86 } 86 }
87 87
88 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( 88 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(
89 int32 thread_id, 89 int32 thread_id,
90 int32 request_id, 90 int32 request_id,
91 int32 provider_id,
91 const GURL& pattern, 92 const GURL& pattern,
92 const GURL& script_url) { 93 const GURL& script_url) {
93 if (!context_ || !context_->IsEnabled()) { 94 if (!context_ || !context_->IsEnabled()) {
94 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 95 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
95 thread_id, 96 thread_id,
96 request_id, 97 request_id,
97 WebServiceWorkerError::DisabledError, 98 WebServiceWorkerError::DisabledError,
98 base::ASCIIToUTF16(kDisabledErrorMessage))); 99 base::ASCIIToUTF16(kDisabledErrorMessage)));
99 return; 100 return;
100 } 101 }
101 102
102 // TODO(alecflett): This check is insufficient for release. Add a 103 // TODO(alecflett): This check is insufficient for release. Add a
103 // ServiceWorker-specific policy query in 104 // ServiceWorker-specific policy query in
104 // ChildProcessSecurityImpl. See http://crbug.com/311631. 105 // ChildProcessSecurityImpl. See http://crbug.com/311631.
105 if (pattern.GetOrigin() != script_url.GetOrigin()) { 106 if (pattern.GetOrigin() != script_url.GetOrigin()) {
106 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 107 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
107 thread_id, 108 thread_id,
108 request_id, 109 request_id,
109 WebServiceWorkerError::SecurityError, 110 WebServiceWorkerError::SecurityError,
110 base::ASCIIToUTF16(kDomainMismatchErrorMessage))); 111 base::ASCIIToUTF16(kDomainMismatchErrorMessage)));
111 return; 112 return;
112 } 113 }
113 114
115 ServiceWorkerProviderHost* provider_host =
116 context_->GetProviderHost(render_process_id_, provider_id);
117 if (!provider_host) {
118 BadMessageReceived();
119 return;
120 }
kinuko 2014/01/29 09:56:20 Do we need this check?
alecflett 2014/01/30 01:51:13 I guess we don't now! (an earlier iteration needed
114 context_->RegisterServiceWorker( 121 context_->RegisterServiceWorker(
115 pattern, 122 pattern,
116 script_url, 123 script_url,
124 render_process_id_,
117 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete, 125 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete,
118 this, 126 this,
119 thread_id, 127 thread_id,
120 request_id)); 128 request_id));
121 } 129 }
122 130
123 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( 131 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(
124 int32 thread_id, 132 int32 thread_id,
125 int32 request_id, 133 int32 request_id,
134 int32 provider_id,
126 const GURL& pattern) { 135 const GURL& pattern) {
127 // TODO(alecflett): This check is insufficient for release. Add a 136 // TODO(alecflett): This check is insufficient for release. Add a
128 // ServiceWorker-specific policy query in 137 // ServiceWorker-specific policy query in
129 // ChildProcessSecurityImpl. See http://crbug.com/311631. 138 // ChildProcessSecurityImpl. See http://crbug.com/311631.
130 if (!context_ || !context_->IsEnabled()) { 139 if (!context_ || !context_->IsEnabled()) {
131 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 140 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
132 thread_id, 141 thread_id,
133 request_id, 142 request_id,
134 blink::WebServiceWorkerError::DisabledError, 143 blink::WebServiceWorkerError::DisabledError,
135 base::ASCIIToUTF16(kDisabledErrorMessage))); 144 base::ASCIIToUTF16(kDisabledErrorMessage)));
136 return; 145 return;
137 } 146 }
138 147
148 ServiceWorkerProviderHost* provider_host =
149 context_->GetProviderHost(render_process_id_, provider_id);
150 if (!provider_host) {
151 BadMessageReceived();
152 return;
153 }
139 context_->UnregisterServiceWorker( 154 context_->UnregisterServiceWorker(
140 pattern, 155 pattern,
156 render_process_id_,
141 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete, 157 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete,
142 this, 158 this,
143 thread_id, 159 thread_id,
144 request_id)); 160 request_id));
145 } 161 }
146 162
147 void ServiceWorkerDispatcherHost::OnProviderCreated(int provider_id) { 163 void ServiceWorkerDispatcherHost::OnProviderCreated(int provider_id) {
148 if (!context_) 164 if (!context_)
149 return; 165 return;
150 if (context_->GetProviderHost(render_process_id_, provider_id)) { 166 if (context_->GetProviderHost(render_process_id_, provider_id)) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 ServiceWorkerStatusCode status) { 238 ServiceWorkerStatusCode status) {
223 base::string16 error_message; 239 base::string16 error_message;
224 blink::WebServiceWorkerError::ErrorType error_type; 240 blink::WebServiceWorkerError::ErrorType error_type;
225 GetServiceWorkerRegistrationStatusResponse( 241 GetServiceWorkerRegistrationStatusResponse(
226 status, &error_type, &error_message); 242 status, &error_type, &error_message);
227 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 243 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
228 thread_id, request_id, error_type, error_message)); 244 thread_id, request_id, error_type, error_message));
229 } 245 }
230 246
231 } // namespace content 247 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698