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/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/browser/message_port_message_filter.h" | 8 #include "content/browser/message_port_message_filter.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_request_handler. h" | 10 #include "content/browser/service_worker/service_worker_context_request_handler. h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 DecreaseProcessReference(*it); | 48 DecreaseProcessReference(*it); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 void ServiceWorkerProviderHost::OnRegistrationFailed( | 52 void ServiceWorkerProviderHost::OnRegistrationFailed( |
53 ServiceWorkerRegistration* registration) { | 53 ServiceWorkerRegistration* registration) { |
54 DCHECK_EQ(associated_registration_.get(), registration); | 54 DCHECK_EQ(associated_registration_.get(), registration); |
55 DisassociateRegistration(); | 55 DisassociateRegistration(); |
56 } | 56 } |
57 | 57 |
58 void ServiceWorkerProviderHost::OnSkippedWaiting( | |
59 ServiceWorkerRegistration* registration) { | |
60 DCHECK_EQ(associated_registration_.get(), registration); | |
61 ServiceWorkerVersion* active_version = registration->active_version(); | |
62 DCHECK_EQ(active_version->status(), ServiceWorkerVersion::ACTIVATING); | |
63 SetControllerVersionAttribute(active_version); | |
64 } | |
65 | |
58 void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) { | 66 void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) { |
59 DCHECK(!url.has_ref()); | 67 DCHECK(!url.has_ref()); |
60 document_url_ = url; | 68 document_url_ = url; |
61 } | 69 } |
62 | 70 |
63 void ServiceWorkerProviderHost::SetTopmostFrameUrl(const GURL& url) { | 71 void ServiceWorkerProviderHost::SetTopmostFrameUrl(const GURL& url) { |
64 topmost_frame_url_ = url; | 72 topmost_frame_url_ = url; |
65 } | 73 } |
66 | 74 |
67 void ServiceWorkerProviderHost::SetControllerVersionAttribute( | 75 void ServiceWorkerProviderHost::SetControllerVersionAttribute( |
68 ServiceWorkerVersion* version) { | 76 ServiceWorkerVersion* version) { |
69 if (version == controlling_version_.get()) | 77 if (version == controlling_version_.get()) |
70 return; | 78 return; |
71 | 79 |
72 scoped_refptr<ServiceWorkerVersion> previous_version = controlling_version_; | 80 scoped_refptr<ServiceWorkerVersion> previous_version = controlling_version_; |
73 controlling_version_ = version; | 81 controlling_version_ = version; |
74 if (version) | 82 if (version) |
75 version->AddControllee(this); | 83 version->AddControllee(this); |
76 if (previous_version.get()) | 84 if (previous_version.get()) |
77 previous_version->RemoveControllee(this); | 85 previous_version->RemoveControllee(this); |
78 | 86 |
79 if (!dispatcher_host_) | 87 if (!dispatcher_host_) |
80 return; // Could be NULL in some tests. | 88 return; // Could be NULL in some tests. |
81 | 89 |
82 dispatcher_host_->Send(new ServiceWorkerMsg_SetControllerServiceWorker( | 90 dispatcher_host_->Send(new ServiceWorkerMsg_SetControllerServiceWorker( |
michaeln
2014/11/25 23:50:22
we could add a param to the msg and method whether
xiang
2014/11/28 08:04:26
Done.
| |
83 kDocumentMainThreadId, provider_id(), CreateHandleAndPass(version))); | 91 kDocumentMainThreadId, provider_id(), CreateHandleAndPass(version))); |
84 } | 92 } |
85 | 93 |
86 bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) { | 94 bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) { |
87 if (!context_) | 95 if (!context_) |
88 return true; // System is shutting down. | 96 return true; // System is shutting down. |
89 if (active_version()) | 97 if (active_version()) |
90 return false; // Unexpected bad message. | 98 return false; // Unexpected bad message. |
91 | 99 |
92 ServiceWorkerVersion* live_version = context_->GetLiveVersion(version_id); | 100 ServiceWorkerVersion* live_version = context_->GetLiveVersion(version_id); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 context_->process_manager()->RemoveProcessReferenceFromPattern( | 252 context_->process_manager()->RemoveProcessReferenceFromPattern( |
245 pattern, process_id_); | 253 pattern, process_id_); |
246 } | 254 } |
247 } | 255 } |
248 | 256 |
249 bool ServiceWorkerProviderHost::IsContextAlive() { | 257 bool ServiceWorkerProviderHost::IsContextAlive() { |
250 return context_ != NULL; | 258 return context_ != NULL; |
251 } | 259 } |
252 | 260 |
253 } // namespace content | 261 } // namespace content |
OLD | NEW |