| 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" |
| 11 #include "content/common/service_worker/service_worker_messages.h" | 11 #include "content/common/service_worker/service_worker_messages.h" |
| 12 #include "content/common/service_worker/service_worker_utils.h" | 12 #include "content/common/service_worker/service_worker_utils.h" |
| 13 #include "content/public/common/browser_side_navigation_policy.h" | 13 #include "content/public/common/browser_side_navigation_policy.h" |
| 14 #include "ipc/ipc_sync_channel.h" |
| 14 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 15 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 15 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 16 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 16 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 17 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const char kUserDataKey[] = "SWProviderKey"; | 23 const char kUserDataKey[] = "SWProviderKey"; |
| 23 | 24 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 int browser_provider_id, | 122 int browser_provider_id, |
| 122 bool is_parent_frame_secure) | 123 bool is_parent_frame_secure) |
| 123 : provider_id_(browser_provider_id) { | 124 : provider_id_(browser_provider_id) { |
| 124 if (provider_id_ == kInvalidServiceWorkerProviderId) | 125 if (provider_id_ == kInvalidServiceWorkerProviderId) |
| 125 return; | 126 return; |
| 126 if (!ChildThreadImpl::current()) | 127 if (!ChildThreadImpl::current()) |
| 127 return; // May be null in some tests. | 128 return; // May be null in some tests. |
| 128 context_ = new ServiceWorkerProviderContext( | 129 context_ = new ServiceWorkerProviderContext( |
| 129 provider_id_, provider_type, | 130 provider_id_, provider_type, |
| 130 ChildThreadImpl::current()->thread_safe_sender()); | 131 ChildThreadImpl::current()->thread_safe_sender()); |
| 131 ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_ProviderCreated( | 132 if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { |
| 132 provider_id_, route_id, provider_type, is_parent_frame_secure)); | 133 ChildThreadImpl::current()->channel()->GetRemoteAssociatedInterface( |
| 134 &dispatcher_host_); |
| 135 dispatcher_host_->OnProviderCreated(provider_id_, route_id, provider_type, |
| 136 is_parent_frame_secure); |
| 137 } else { |
| 138 ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_ProviderCreated( |
| 139 provider_id_, route_id, provider_type, is_parent_frame_secure)); |
| 140 } |
| 133 } | 141 } |
| 134 | 142 |
| 135 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( | 143 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( |
| 136 int route_id, | 144 int route_id, |
| 137 ServiceWorkerProviderType provider_type, | 145 ServiceWorkerProviderType provider_type, |
| 138 bool is_parent_frame_secure) | 146 bool is_parent_frame_secure) |
| 139 : ServiceWorkerNetworkProvider(route_id, | 147 : ServiceWorkerNetworkProvider(route_id, |
| 140 provider_type, | 148 provider_type, |
| 141 GetNextProviderId(), | 149 GetNextProviderId(), |
| 142 is_parent_frame_secure) {} | 150 is_parent_frame_secure) {} |
| (...skipping 18 matching lines...) Expand all Loading... |
| 161 return; // May be null in some tests. | 169 return; // May be null in some tests. |
| 162 ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_SetVersionId( | 170 ChildThreadImpl::current()->Send(new ServiceWorkerHostMsg_SetVersionId( |
| 163 provider_id_, version_id, embedded_worker_id)); | 171 provider_id_, version_id, embedded_worker_id)); |
| 164 } | 172 } |
| 165 | 173 |
| 166 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const { | 174 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const { |
| 167 return context() && context()->controller(); | 175 return context() && context()->controller(); |
| 168 } | 176 } |
| 169 | 177 |
| 170 } // namespace content | 178 } // namespace content |
| OLD | NEW |