| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (params.url != pending->instance()->url()) | |
| 315 return blink::WebWorkerCreationErrorURLMismatch; | |
| 316 pending->AddRequest(std::move(request)); | 314 pending->AddRequest(std::move(request)); |
| 317 if (params.creation_context_type != | 315 if (params.creation_context_type != |
| 318 pending->instance()->creation_context_type()) | 316 pending->instance()->creation_context_type()) |
| 319 return blink::WebWorkerCreationErrorSecureContextMismatch; | 317 return blink::WebWorkerCreationErrorSecureContextMismatch; |
| 320 return blink::WebWorkerCreationErrorNone; | 318 return blink::WebWorkerCreationErrorNone; |
| 321 } | 319 } |
| 322 | 320 |
| 323 std::unique_ptr<SharedWorkerPendingInstance> pending_instance( | 321 std::unique_ptr<SharedWorkerPendingInstance> pending_instance( |
| 324 new SharedWorkerPendingInstance(std::move(instance))); | 322 new SharedWorkerPendingInstance(std::move(instance))); |
| 325 pending_instance->AddRequest(std::move(request)); | 323 pending_instance->AddRequest(std::move(request)); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 if (!pending_instance->requests()->size()) | 484 if (!pending_instance->requests()->size()) |
| 487 return blink::WebWorkerCreationErrorNone; | 485 return blink::WebWorkerCreationErrorNone; |
| 488 | 486 |
| 489 int worker_process_id = -1; | 487 int worker_process_id = -1; |
| 490 int worker_route_id = MSG_ROUTING_NONE; | 488 int worker_route_id = MSG_ROUTING_NONE; |
| 491 bool is_new_worker = true; | 489 bool is_new_worker = true; |
| 492 blink::WebWorkerCreationError creation_error = | 490 blink::WebWorkerCreationError creation_error = |
| 493 blink::WebWorkerCreationErrorNone; | 491 blink::WebWorkerCreationErrorNone; |
| 494 SharedWorkerHost* host = FindSharedWorkerHost(*pending_instance->instance()); | 492 SharedWorkerHost* host = FindSharedWorkerHost(*pending_instance->instance()); |
| 495 if (host) { | 493 if (host) { |
| 496 if (pending_instance->instance()->url() != host->instance()->url()) | |
| 497 return blink::WebWorkerCreationErrorURLMismatch; | |
| 498 if (pending_instance->instance()->creation_context_type() != | 494 if (pending_instance->instance()->creation_context_type() != |
| 499 host->instance()->creation_context_type()) { | 495 host->instance()->creation_context_type()) { |
| 500 creation_error = blink::WebWorkerCreationErrorSecureContextMismatch; | 496 creation_error = blink::WebWorkerCreationErrorSecureContextMismatch; |
| 501 } | 497 } |
| 502 worker_process_id = host->process_id(); | 498 worker_process_id = host->process_id(); |
| 503 worker_route_id = host->worker_route_id(); | 499 worker_route_id = host->worker_route_id(); |
| 504 is_new_worker = false; | 500 is_new_worker = false; |
| 505 } else { | 501 } else { |
| 506 SharedWorkerMessageFilter* first_filter = | 502 SharedWorkerMessageFilter* first_filter = |
| 507 (*pending_instance->requests()->begin())->filter; | 503 (*pending_instance->requests()->begin())->filter; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 UpdateWorkerDependencyFunc new_func) { | 672 UpdateWorkerDependencyFunc new_func) { |
| 677 update_worker_dependency_ = new_func; | 673 update_worker_dependency_ = new_func; |
| 678 } | 674 } |
| 679 | 675 |
| 680 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( | 676 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( |
| 681 bool (*new_func)(int)) { | 677 bool (*new_func)(int)) { |
| 682 s_try_increment_worker_ref_count_ = new_func; | 678 s_try_increment_worker_ref_count_ = new_func; |
| 683 } | 679 } |
| 684 | 680 |
| 685 } // namespace content | 681 } // namespace content |
| OLD | NEW |