| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/workers/Worker.h" | 6 #include "core/workers/Worker.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "core/frame/UseCounter.h" | 11 #include "core/frame/UseCounter.h" |
| 12 #include "core/workers/WorkerGlobalScopeProxy.h" | 12 #include "core/workers/WorkerGlobalScopeProxy.h" |
| 13 #include "core/workers/WorkerGlobalScopeProxyProvider.h" | 13 #include "core/workers/WorkerGlobalScopeProxyProvider.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 Worker::Worker(ExecutionContext* context) | 17 Worker::Worker(ExecutionContext* context) |
| 18 : InProcessWorkerBase(context) | 18 : InProcessWorkerBase(context) |
| 19 { | 19 { |
| 20 } | 20 } |
| 21 | 21 |
| 22 PassRefPtrWillBeRawPtr<Worker> Worker::create(ExecutionContext* context, const S
tring& url, ExceptionState& exceptionState) | 22 Worker* Worker::create(ExecutionContext* context, const String& url, ExceptionSt
ate& exceptionState) |
| 23 { | 23 { |
| 24 ASSERT(isMainThread()); | 24 ASSERT(isMainThread()); |
| 25 Document* document = toDocument(context); | 25 Document* document = toDocument(context); |
| 26 UseCounter::count(context, UseCounter::WorkerStart); | 26 UseCounter::count(context, UseCounter::WorkerStart); |
| 27 if (!document->page()) { | 27 if (!document->page()) { |
| 28 exceptionState.throwDOMException(InvalidAccessError, "The context provid
ed is invalid."); | 28 exceptionState.throwDOMException(InvalidAccessError, "The context provid
ed is invalid."); |
| 29 return nullptr; | 29 return nullptr; |
| 30 } | 30 } |
| 31 RefPtrWillBeRawPtr<Worker> worker = adoptRefWillBeNoop(new Worker(context)); | 31 Worker* worker = new Worker(context); |
| 32 if (worker->initialize(context, url, exceptionState)) | 32 if (worker->initialize(context, url, exceptionState)) |
| 33 return worker.release(); | 33 return worker; |
| 34 return nullptr; | 34 return nullptr; |
| 35 } | 35 } |
| 36 | 36 |
| 37 Worker::~Worker() | 37 Worker::~Worker() |
| 38 { | 38 { |
| 39 ASSERT(isMainThread()); | 39 ASSERT(isMainThread()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 const AtomicString& Worker::interfaceName() const | 42 const AtomicString& Worker::interfaceName() const |
| 43 { | 43 { |
| 44 return EventTargetNames::Worker; | 44 return EventTargetNames::Worker; |
| 45 } | 45 } |
| 46 | 46 |
| 47 WorkerGlobalScopeProxy* Worker::createWorkerGlobalScopeProxy(ExecutionContext* c
ontext) | 47 WorkerGlobalScopeProxy* Worker::createWorkerGlobalScopeProxy(ExecutionContext* c
ontext) |
| 48 { | 48 { |
| 49 Document* document = toDocument(context); | 49 Document* document = toDocument(context); |
| 50 WorkerGlobalScopeProxyProvider* proxyProvider = WorkerGlobalScopeProxyProvid
er::from(*document->page()); | 50 WorkerGlobalScopeProxyProvider* proxyProvider = WorkerGlobalScopeProxyProvid
er::from(*document->page()); |
| 51 ASSERT(proxyProvider); | 51 ASSERT(proxyProvider); |
| 52 return proxyProvider->createWorkerGlobalScopeProxy(this); | 52 return proxyProvider->createWorkerGlobalScopeProxy(this); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |