Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp

Issue 2840473002: Worker: Remove WorkerLoaderProxy for clean-up (Closed)
Patch Set: clean up Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ThreadedMessagingProxyBase.h" 5 #include "core/workers/ThreadedMessagingProxyBase.h"
6 6
7 #include "bindings/core/v8/SourceLocation.h" 7 #include "bindings/core/v8/SourceLocation.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/TaskRunnerHelper.h" 9 #include "core/dom/TaskRunnerHelper.h"
10 #include "core/frame/Deprecation.h" 10 #include "core/frame/Deprecation.h"
(...skipping 18 matching lines...) Expand all
29 parent_frame_task_runners_(ParentFrameTaskRunners::Create( 29 parent_frame_task_runners_(ParentFrameTaskRunners::Create(
30 ToDocument(execution_context_.Get())->GetFrame())), 30 ToDocument(execution_context_.Get())->GetFrame())),
31 may_be_destroyed_(false), 31 may_be_destroyed_(false),
32 asked_to_terminate_(false) { 32 asked_to_terminate_(false) {
33 DCHECK(IsParentContextThread()); 33 DCHECK(IsParentContextThread());
34 g_live_messaging_proxy_count++; 34 g_live_messaging_proxy_count++;
35 } 35 }
36 36
37 ThreadedMessagingProxyBase::~ThreadedMessagingProxyBase() { 37 ThreadedMessagingProxyBase::~ThreadedMessagingProxyBase() {
38 DCHECK(IsParentContextThread()); 38 DCHECK(IsParentContextThread());
39 if (loader_proxy_)
40 loader_proxy_->DetachProvider(this);
41 g_live_messaging_proxy_count--; 39 g_live_messaging_proxy_count--;
42 } 40 }
43 41
44 int ThreadedMessagingProxyBase::ProxyCount() { 42 int ThreadedMessagingProxyBase::ProxyCount() {
45 DCHECK(IsMainThread()); 43 DCHECK(IsMainThread());
46 return g_live_messaging_proxy_count; 44 return g_live_messaging_proxy_count;
47 } 45 }
48 46
49 void ThreadedMessagingProxyBase::SetWorkerThreadForTest( 47 void ThreadedMessagingProxyBase::SetWorkerThreadForTest(
50 std::unique_ptr<WorkerThread> worker_thread) { 48 std::unique_ptr<WorkerThread> worker_thread) {
51 worker_thread_ = std::move(worker_thread); 49 worker_thread_ = std::move(worker_thread);
52 } 50 }
53 51
54 void ThreadedMessagingProxyBase::InitializeWorkerThread( 52 void ThreadedMessagingProxyBase::InitializeWorkerThread(
55 std::unique_ptr<WorkerThreadStartupData> startup_data) { 53 std::unique_ptr<WorkerThreadStartupData> startup_data) {
56 DCHECK(IsParentContextThread()); 54 DCHECK(IsParentContextThread());
57 55
58 Document* document = ToDocument(GetExecutionContext()); 56 Document* document = ToDocument(GetExecutionContext());
59 double origin_time = 57 double origin_time =
60 document->Loader() 58 document->Loader()
61 ? document->Loader()->GetTiming().ReferenceMonotonicTime() 59 ? document->Loader()->GetTiming().ReferenceMonotonicTime()
62 : MonotonicallyIncreasingTime(); 60 : MonotonicallyIncreasingTime();
63 61
64 loader_proxy_ = WorkerLoaderProxy::Create(this);
65 worker_thread_ = CreateWorkerThread(origin_time); 62 worker_thread_ = CreateWorkerThread(origin_time);
66 worker_thread_->Start(std::move(startup_data), GetParentFrameTaskRunners()); 63 worker_thread_->Start(std::move(startup_data), GetParentFrameTaskRunners());
67 WorkerThreadCreated(); 64 WorkerThreadCreated();
68 } 65 }
69 66
70 ThreadableLoadingContext* 67 ThreadableLoadingContext*
71 ThreadedMessagingProxyBase::GetThreadableLoadingContext() { 68 ThreadedMessagingProxyBase::GetThreadableLoadingContext() {
72 DCHECK(IsParentContextThread()); 69 DCHECK(IsParentContextThread());
73 if (!loading_context_) { 70 return ThreadableLoadingContext::Create(*ToDocument(execution_context_));
74 loading_context_ =
75 ThreadableLoadingContext::Create(*ToDocument(execution_context_));
76 }
77 return loading_context_;
78 } 71 }
79 72
80 void ThreadedMessagingProxyBase::CountFeature(UseCounter::Feature feature) { 73 void ThreadedMessagingProxyBase::CountFeature(UseCounter::Feature feature) {
81 DCHECK(IsParentContextThread()); 74 DCHECK(IsParentContextThread());
82 UseCounter::Count(execution_context_, feature); 75 UseCounter::Count(execution_context_, feature);
83 } 76 }
84 77
85 void ThreadedMessagingProxyBase::CountDeprecation(UseCounter::Feature feature) { 78 void ThreadedMessagingProxyBase::CountDeprecation(UseCounter::Feature feature) {
86 DCHECK(IsParentContextThread()); 79 DCHECK(IsParentContextThread());
87 Deprecation::CountDeprecation(execution_context_, feature); 80 Deprecation::CountDeprecation(execution_context_, feature);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 153 }
161 154
162 bool ThreadedMessagingProxyBase::IsParentContextThread() const { 155 bool ThreadedMessagingProxyBase::IsParentContextThread() const {
163 // TODO(nhiroki): Nested worker is not supported yet, so the parent context 156 // TODO(nhiroki): Nested worker is not supported yet, so the parent context
164 // thread should be equal to the main thread (http://crbug.com/31666). 157 // thread should be equal to the main thread (http://crbug.com/31666).
165 DCHECK(execution_context_->IsDocument()); 158 DCHECK(execution_context_->IsDocument());
166 return IsMainThread(); 159 return IsMainThread();
167 } 160 }
168 161
169 } // namespace blink 162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698