| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/workers/Worker.h" | 5 #include "core/workers/Worker.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
| 11 #include "core/workers/DedicatedWorkerMessagingProxyProvider.h" | 11 #include "core/frame/WebLocalFrameBase.h" |
| 12 #include "core/workers/InProcessWorkerMessagingProxy.h" | 12 #include "core/workers/DedicatedWorkerMessagingProxy.h" |
| 13 #include "core/workers/WorkerContentSettingsClient.h" |
| 14 #include "public/platform/WebContentSettingsClient.h" |
| 15 #include "public/web/WebFrameClient.h" |
| 13 | 16 |
| 14 namespace blink { | 17 namespace blink { |
| 15 | 18 |
| 19 template class CORE_TEMPLATE_EXPORT WorkerClientsInitializer<Worker>; |
| 20 |
| 16 Worker::Worker(ExecutionContext* context) : InProcessWorkerBase(context) {} | 21 Worker::Worker(ExecutionContext* context) : InProcessWorkerBase(context) {} |
| 17 | 22 |
| 18 Worker* Worker::Create(ExecutionContext* context, | 23 Worker* Worker::Create(ExecutionContext* context, |
| 19 const String& url, | 24 const String& url, |
| 20 ExceptionState& exception_state) { | 25 ExceptionState& exception_state) { |
| 21 DCHECK(IsMainThread()); | 26 DCHECK(IsMainThread()); |
| 22 Document* document = ToDocument(context); | 27 Document* document = ToDocument(context); |
| 23 UseCounter::Count(context, WebFeature::kWorkerStart); | 28 UseCounter::Count(context, WebFeature::kWorkerStart); |
| 24 if (!document->GetPage()) { | 29 if (!document->GetPage()) { |
| 25 exception_state.ThrowDOMException(kInvalidAccessError, | 30 exception_state.ThrowDOMException(kInvalidAccessError, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 DCHECK(IsMainThread()); | 41 DCHECK(IsMainThread()); |
| 37 } | 42 } |
| 38 | 43 |
| 39 const AtomicString& Worker::InterfaceName() const { | 44 const AtomicString& Worker::InterfaceName() const { |
| 40 return EventTargetNames::Worker; | 45 return EventTargetNames::Worker; |
| 41 } | 46 } |
| 42 | 47 |
| 43 InProcessWorkerMessagingProxy* Worker::CreateInProcessWorkerMessagingProxy( | 48 InProcessWorkerMessagingProxy* Worker::CreateInProcessWorkerMessagingProxy( |
| 44 ExecutionContext* context) { | 49 ExecutionContext* context) { |
| 45 Document* document = ToDocument(context); | 50 Document* document = ToDocument(context); |
| 46 DedicatedWorkerMessagingProxyProvider* proxy_provider = | 51 WebLocalFrameBase* web_frame = |
| 47 DedicatedWorkerMessagingProxyProvider::From(*document->GetPage()); | 52 WebLocalFrameBase::FromFrame(document->GetFrame()); |
| 48 DCHECK(proxy_provider); | 53 |
| 49 return proxy_provider->CreateWorkerMessagingProxy(this); | 54 WorkerClients* worker_clients = WorkerClients::Create(); |
| 55 WorkerClientsInitializer<Worker>::Run(worker_clients); |
| 56 ProvideContentSettingsClientToWorker( |
| 57 worker_clients, web_frame->Client()->CreateWorkerContentSettingsClient()); |
| 58 return new DedicatedWorkerMessagingProxy(this, worker_clients); |
| 50 } | 59 } |
| 51 | 60 |
| 52 } // namespace blink | 61 } // namespace blink |
| OLD | NEW |