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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "content/browser/devtools/shared_worker_devtools_manager.h" | 16 #include "content/browser/devtools/shared_worker_devtools_manager.h" |
17 #include "content/browser/renderer_host/render_process_host_impl.h" | 17 #include "content/browser/renderer_host/render_process_host_impl.h" |
18 #include "content/browser/shared_worker/shared_worker_host.h" | 18 #include "content/browser/shared_worker/shared_worker_host.h" |
19 #include "content/browser/shared_worker/shared_worker_instance.h" | 19 #include "content/browser/shared_worker/shared_worker_instance.h" |
20 #include "content/browser/shared_worker/shared_worker_message_filter.h" | 20 #include "content/browser/shared_worker/shared_worker_message_filter.h" |
21 #include "content/browser/shared_worker/worker_document_set.h" | 21 #include "content/browser/shared_worker/worker_document_set.h" |
22 #include "content/common/view_messages.h" | 22 #include "content/common/view_messages.h" |
23 #include "content/common/worker_messages.h" | 23 #include "content/common/worker_messages.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/worker_service_observer.h" | 25 #include "content/public/browser/worker_service_observer.h" |
| 26 #include "third_party/WebKit/public/web/WebDataSaverFlag.h" |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 | 29 |
29 WorkerService* WorkerService::GetInstance() { | 30 WorkerService* WorkerService::GetInstance() { |
30 return SharedWorkerServiceImpl::GetInstance(); | 31 return SharedWorkerServiceImpl::GetInstance(); |
31 } | 32 } |
32 | 33 |
33 bool IsHostAlive(RenderProcessHostImpl* host) { | 34 bool IsHostAlive(RenderProcessHostImpl* host) { |
34 return host && !host->FastShutdownStarted() && | 35 return host && !host->FastShutdownStarted() && |
35 !host->IsWorkerRefCountDisabled(); | 36 !host->IsWorkerRefCountDisabled(); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 blink::WebWorkerCreationError SharedWorkerServiceImpl::CreateWorker( | 329 blink::WebWorkerCreationError SharedWorkerServiceImpl::CreateWorker( |
329 const ViewHostMsg_CreateWorker_Params& params, | 330 const ViewHostMsg_CreateWorker_Params& params, |
330 int route_id, | 331 int route_id, |
331 SharedWorkerMessageFilter* filter, | 332 SharedWorkerMessageFilter* filter, |
332 ResourceContext* resource_context, | 333 ResourceContext* resource_context, |
333 const WorkerStoragePartitionId& partition_id) { | 334 const WorkerStoragePartitionId& partition_id) { |
334 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 335 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
335 std::unique_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance( | 336 std::unique_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance( |
336 params.url, params.name, params.content_security_policy, | 337 params.url, params.name, params.content_security_policy, |
337 params.security_policy_type, params.creation_address_space, | 338 params.security_policy_type, params.creation_address_space, |
338 resource_context, partition_id, params.creation_context_type)); | 339 resource_context, partition_id, params.creation_context_type, |
| 340 params.data_saver_flag)); |
339 std::unique_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> | 341 std::unique_ptr<SharedWorkerPendingInstance::SharedWorkerPendingRequest> |
340 request(new SharedWorkerPendingInstance::SharedWorkerPendingRequest( | 342 request(new SharedWorkerPendingInstance::SharedWorkerPendingRequest( |
341 filter, route_id, params.document_id, filter->render_process_id(), | 343 filter, route_id, params.document_id, filter->render_process_id(), |
342 params.render_frame_route_id)); | 344 params.render_frame_route_id)); |
343 if (SharedWorkerPendingInstance* pending = FindPendingInstance(*instance)) { | 345 if (SharedWorkerPendingInstance* pending = FindPendingInstance(*instance)) { |
344 pending->AddRequest(std::move(request)); | 346 pending->AddRequest(std::move(request)); |
345 if (params.creation_context_type != | 347 if (params.creation_context_type != |
346 pending->instance()->creation_context_type()) | 348 pending->instance()->creation_context_type()) |
347 return blink::kWebWorkerCreationErrorSecureContextMismatch; | 349 return blink::kWebWorkerCreationErrorSecureContextMismatch; |
348 return blink::kWebWorkerCreationErrorNone; | 350 return blink::kWebWorkerCreationErrorNone; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 UpdateWorkerDependencyFunc new_func) { | 694 UpdateWorkerDependencyFunc new_func) { |
693 update_worker_dependency_ = new_func; | 695 update_worker_dependency_ = new_func; |
694 } | 696 } |
695 | 697 |
696 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( | 698 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( |
697 bool (*new_func)(int)) { | 699 bool (*new_func)(int)) { |
698 s_try_increment_worker_ref_count_ = new_func; | 700 s_try_increment_worker_ref_count_ = new_func; |
699 } | 701 } |
700 | 702 |
701 } // namespace content | 703 } // namespace content |
OLD | NEW |