| 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::SharedWorkerCreateParamsPtr 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 params->security_policy_type, params->creation_address_space, |
| 308 resource_context, partition_id, params.creation_context_type)); | 308 resource_context, partition_id, params->creation_context_type)); |
| 309 std::unique_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> | 309 std::unique_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> |
| 310 request(new SharedWorkerPendingInstance::SharedWorkerPendingRequest( | 310 request(new SharedWorkerPendingInstance::SharedWorkerPendingRequest( |
| 311 filter, route_id, params.document_id, filter->render_process_id(), | 311 filter, route_id, params->document_id, filter->render_process_id(), |
| 312 params.render_frame_route_id)); | 312 params->render_frame_route_id)); |
| 313 if (SharedWorkerPendingInstance* pending = FindPendingInstance(*instance)) { | 313 if (SharedWorkerPendingInstance* pending = FindPendingInstance(*instance)) { |
| 314 pending->AddRequest(std::move(request)); | 314 pending->AddRequest(std::move(request)); |
| 315 if (params.creation_context_type != | 315 if (params->creation_context_type != |
| 316 pending->instance()->creation_context_type()) | 316 pending->instance()->creation_context_type()) |
| 317 return blink::WebWorkerCreationErrorSecureContextMismatch; | 317 return blink::WebWorkerCreationErrorSecureContextMismatch; |
| 318 return blink::WebWorkerCreationErrorNone; | 318 return blink::WebWorkerCreationErrorNone; |
| 319 } | 319 } |
| 320 | 320 |
| 321 std::unique_ptr<SharedWorkerPendingInstance> pending_instance( | 321 std::unique_ptr<SharedWorkerPendingInstance> pending_instance( |
| 322 new SharedWorkerPendingInstance(std::move(instance))); | 322 new SharedWorkerPendingInstance(std::move(instance))); |
| 323 pending_instance->AddRequest(std::move(request)); | 323 pending_instance->AddRequest(std::move(request)); |
| 324 return ReserveRenderProcessToCreateWorker(std::move(pending_instance)); | 324 return ReserveRenderProcessToCreateWorker(std::move(pending_instance)); |
| 325 } | 325 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 UpdateWorkerDependencyFunc new_func) { | 670 UpdateWorkerDependencyFunc new_func) { |
| 671 update_worker_dependency_ = new_func; | 671 update_worker_dependency_ = new_func; |
| 672 } | 672 } |
| 673 | 673 |
| 674 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( | 674 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( |
| 675 bool (*new_func)(int)) { | 675 bool (*new_func)(int)) { |
| 676 s_try_increment_worker_ref_count_ = new_func; | 676 s_try_increment_worker_ref_count_ = new_func; |
| 677 } | 677 } |
| 678 | 678 |
| 679 } // namespace content | 679 } // namespace content |
| OLD | NEW |