OLD | NEW |
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_provider_host.h" | 5 #include "content/browser/service_worker/service_worker_provider_host.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 if (!dispatcher_host_) | 185 if (!dispatcher_host_) |
186 return; // Could be NULL in some tests. | 186 return; // Could be NULL in some tests. |
187 | 187 |
188 // SetController message should be sent only for controllees. | 188 // SetController message should be sent only for controllees. |
189 DCHECK(IsProviderForClient()); | 189 DCHECK(IsProviderForClient()); |
190 Send(new ServiceWorkerMsg_SetControllerServiceWorker( | 190 Send(new ServiceWorkerMsg_SetControllerServiceWorker( |
191 render_thread_id_, provider_id(), GetOrCreateServiceWorkerHandle(version), | 191 render_thread_id_, provider_id(), GetOrCreateServiceWorkerHandle(version), |
192 notify_controllerchange)); | 192 notify_controllerchange)); |
193 } | 193 } |
194 | 194 |
195 bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) { | 195 bool ServiceWorkerProviderHost::SetHostedVersionId(std::string version_uuid) { |
196 if (!context_) | 196 if (!context_) |
197 return true; // System is shutting down. | 197 return true; // System is shutting down. |
198 if (active_version()) | 198 if (active_version()) |
199 return false; // Unexpected bad message. | 199 return false; // Unexpected bad message. |
200 | 200 |
201 ServiceWorkerVersion* live_version = context_->GetLiveVersion(version_id); | 201 ServiceWorkerVersion* live_version = context_->GetLiveVersion(version_uuid); |
202 if (!live_version) | 202 if (!live_version) |
203 return true; // Was deleted before it got started. | 203 return true; // Was deleted before it got started. |
204 | 204 |
205 ServiceWorkerVersionInfo info = live_version->GetInfo(); | 205 ServiceWorkerVersionInfo info = live_version->GetInfo(); |
206 if (info.running_status != ServiceWorkerVersion::STARTING || | 206 if (info.running_status != ServiceWorkerVersion::STARTING || |
207 info.process_id != render_process_id_) { | 207 info.process_id != render_process_id_) { |
208 // If we aren't trying to start this version in our process | 208 // If we aren't trying to start this version in our process |
209 // something is amiss. | 209 // something is amiss. |
210 return false; | 210 return false; |
211 } | 211 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return scoped_ptr<ServiceWorkerRequestHandler>(); | 358 return scoped_ptr<ServiceWorkerRequestHandler>(); |
359 } | 359 } |
360 | 360 |
361 ServiceWorkerObjectInfo | 361 ServiceWorkerObjectInfo |
362 ServiceWorkerProviderHost::GetOrCreateServiceWorkerHandle( | 362 ServiceWorkerProviderHost::GetOrCreateServiceWorkerHandle( |
363 ServiceWorkerVersion* version) { | 363 ServiceWorkerVersion* version) { |
364 DCHECK(dispatcher_host_); | 364 DCHECK(dispatcher_host_); |
365 if (!context_ || !version) | 365 if (!context_ || !version) |
366 return ServiceWorkerObjectInfo(); | 366 return ServiceWorkerObjectInfo(); |
367 ServiceWorkerHandle* handle = dispatcher_host_->FindServiceWorkerHandle( | 367 ServiceWorkerHandle* handle = dispatcher_host_->FindServiceWorkerHandle( |
368 provider_id(), version->version_id()); | 368 provider_id(), version->version_uuid()); |
369 if (handle) { | 369 if (handle) { |
370 handle->IncrementRefCount(); | 370 handle->IncrementRefCount(); |
371 return handle->GetObjectInfo(); | 371 return handle->GetObjectInfo(); |
372 } | 372 } |
373 | 373 |
374 scoped_ptr<ServiceWorkerHandle> new_handle( | 374 scoped_ptr<ServiceWorkerHandle> new_handle( |
375 ServiceWorkerHandle::Create(context_, AsWeakPtr(), version)); | 375 ServiceWorkerHandle::Create(context_, AsWeakPtr(), version)); |
376 handle = new_handle.get(); | 376 handle = new_handle.get(); |
377 dispatcher_host_->RegisterServiceWorkerHandle(new_handle.Pass()); | 377 dispatcher_host_->RegisterServiceWorkerHandle(new_handle.Pass()); |
378 return handle->GetObjectInfo(); | 378 return handle->GetObjectInfo(); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 return context_ != NULL; | 677 return context_ != NULL; |
678 } | 678 } |
679 | 679 |
680 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { | 680 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { |
681 DCHECK(dispatcher_host_); | 681 DCHECK(dispatcher_host_); |
682 DCHECK(IsReadyToSendMessages()); | 682 DCHECK(IsReadyToSendMessages()); |
683 dispatcher_host_->Send(message); | 683 dispatcher_host_->Send(message); |
684 } | 684 } |
685 | 685 |
686 } // namespace content | 686 } // namespace content |
OLD | NEW |