| 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/browser/shared_worker/shared_worker_service_impl.h" | 5 #include "content/browser/shared_worker/shared_worker_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 289 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 290 observers_.AddObserver(observer); | 290 observers_.AddObserver(observer); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void SharedWorkerServiceImpl::RemoveObserver(WorkerServiceObserver* observer) { | 293 void SharedWorkerServiceImpl::RemoveObserver(WorkerServiceObserver* observer) { |
| 294 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 294 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 295 observers_.RemoveObserver(observer); | 295 observers_.RemoveObserver(observer); |
| 296 } | 296 } |
| 297 | 297 |
| 298 blink::WebWorkerCreationError SharedWorkerServiceImpl::CreateWorker( | 298 blink::WebWorkerCreationError SharedWorkerServiceImpl::CreateWorker( |
| 299 const ViewHostMsg_CreateWorker_Params& params, | 299 mojom::SharedWorker_CreateWorker_ParamsPtr params, |
| 300 int route_id, | 300 int route_id, |
| 301 SharedWorkerMessageFilter* filter, | 301 SharedWorkerMessageFilter* filter, |
| 302 ResourceContext* resource_context, | 302 ResourceContext* resource_context, |
| 303 const WorkerStoragePartitionId& partition_id) { | 303 const WorkerStoragePartitionId& partition_id) { |
| 304 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 304 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 305 std::unique_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance( | 305 std::unique_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance( |
| 306 params.url, params.name, params.content_security_policy, | 306 params->url, params->name, params->content_security_policy, |
| 307 params.security_policy_type, params.creation_address_space, | 307 static_cast<blink::WebContentSecurityPolicyType>( |
| 308 resource_context, partition_id, params.creation_context_type)); | 308 params->security_policy_type), |
| 309 static_cast<blink::WebAddressSpace>(params->creation_address_space), |
| 310 resource_context, partition_id, |
| 311 static_cast<blink::WebSharedWorkerCreationContextType>( |
| 312 params->creation_context_type))); |
| 309 std::unique_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> | 313 std::unique_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> |
| 310 request(new SharedWorkerPendingInstance::SharedWorkerPendingRequest( | 314 request(new SharedWorkerPendingInstance::SharedWorkerPendingRequest( |
| 311 filter, route_id, params.document_id, filter->render_process_id(), | 315 filter, route_id, params->document_id, filter->render_process_id(), |
| 312 params.render_frame_route_id)); | 316 params->render_frame_route_id)); |
| 313 if (SharedWorkerPendingInstance* pending = FindPendingInstance(*instance)) { | 317 if (SharedWorkerPendingInstance* pending = FindPendingInstance(*instance)) { |
| 314 pending->AddRequest(std::move(request)); | 318 pending->AddRequest(std::move(request)); |
| 315 if (params.creation_context_type != | 319 if (static_cast<blink::WebSharedWorkerCreationContextType>( |
| 320 params->creation_context_type) != |
| 316 pending->instance()->creation_context_type()) | 321 pending->instance()->creation_context_type()) |
| 317 return blink::WebWorkerCreationErrorSecureContextMismatch; | 322 return blink::WebWorkerCreationErrorSecureContextMismatch; |
| 318 return blink::WebWorkerCreationErrorNone; | 323 return blink::WebWorkerCreationErrorNone; |
| 319 } | 324 } |
| 320 | 325 |
| 321 std::unique_ptr<SharedWorkerPendingInstance> pending_instance( | 326 std::unique_ptr<SharedWorkerPendingInstance> pending_instance( |
| 322 new SharedWorkerPendingInstance(std::move(instance))); | 327 new SharedWorkerPendingInstance(std::move(instance))); |
| 323 pending_instance->AddRequest(std::move(request)); | 328 pending_instance->AddRequest(std::move(request)); |
| 324 return ReserveRenderProcessToCreateWorker(std::move(pending_instance)); | 329 return ReserveRenderProcessToCreateWorker(std::move(pending_instance)); |
| 325 } | 330 } |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 UpdateWorkerDependencyFunc new_func) { | 680 UpdateWorkerDependencyFunc new_func) { |
| 676 update_worker_dependency_ = new_func; | 681 update_worker_dependency_ = new_func; |
| 677 } | 682 } |
| 678 | 683 |
| 679 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( | 684 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( |
| 680 bool (*new_func)(int)) { | 685 bool (*new_func)(int)) { |
| 681 s_try_increment_worker_ref_count_ = new_func; | 686 s_try_increment_worker_ref_count_ = new_func; |
| 682 } | 687 } |
| 683 | 688 |
| 684 } // namespace content | 689 } // namespace content |
| OLD | NEW |