| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/service_worker/service_worker_network_provider.h" | 5 #include "content/child/service_worker/service_worker_network_provider.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "content/child/child_thread_impl.h" | 8 #include "content/child/child_thread_impl.h" |
| 9 #include "content/child/service_worker/service_worker_provider_context.h" | 9 #include "content/child/service_worker/service_worker_provider_context.h" |
| 10 #include "content/common/navigation_params.h" | 10 #include "content/common/navigation_params.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 is_parent_frame_secure) {} | 150 is_parent_frame_secure) {} |
| 151 | 151 |
| 152 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider() | 152 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider() |
| 153 : provider_id_(kInvalidServiceWorkerProviderId) {} | 153 : provider_id_(kInvalidServiceWorkerProviderId) {} |
| 154 | 154 |
| 155 ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() { | 155 ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() { |
| 156 if (provider_id_ == kInvalidServiceWorkerProviderId) | 156 if (provider_id_ == kInvalidServiceWorkerProviderId) |
| 157 return; | 157 return; |
| 158 if (!ChildThreadImpl::current()) | 158 if (!ChildThreadImpl::current()) |
| 159 return; // May be null in some tests. | 159 return; // May be null in some tests. |
| 160 ChildThreadImpl::current()->Send( | 160 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { |
| 161 new ServiceWorkerHostMsg_ProviderDestroyed(provider_id_)); | 161 dispatcher_host_->OnProviderDestroyed(provider_id()); |
| 162 } else { |
| 163 ChildThreadImpl::current()->Send( |
| 164 new ServiceWorkerHostMsg_ProviderDestroyed(provider_id_)); |
| 165 } |
| 162 } | 166 } |
| 163 | 167 |
| 164 void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId( | 168 void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId( |
| 165 int64_t version_id, | 169 int64_t version_id, |
| 166 int embedded_worker_id) { | 170 int embedded_worker_id) { |
| 167 DCHECK_NE(kInvalidServiceWorkerProviderId, provider_id_); | 171 DCHECK_NE(kInvalidServiceWorkerProviderId, provider_id_); |
| 168 if (!ChildThreadImpl::current()) | 172 if (!ChildThreadImpl::current()) |
| 169 return; // May be null in some tests. | 173 return; // May be null in some tests. |
| 170 ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_SetVersionId( | 174 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { |
| 171 provider_id_, version_id, embedded_worker_id)); | 175 dispatcher_host_->OnSetHostedVersionId(provider_id(), version_id, |
| 176 embedded_worker_id); |
| 177 } else { |
| 178 ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_SetVersionId( |
| 179 provider_id_, version_id, embedded_worker_id)); |
| 180 } |
| 172 } | 181 } |
| 173 | 182 |
| 174 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const { | 183 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const { |
| 175 return context() && context()->controller(); | 184 return context() && context()->controller(); |
| 176 } | 185 } |
| 177 | 186 |
| 178 } // namespace content | 187 } // namespace content |
| OLD | NEW |