OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/loader/ThreadableLoadingContext.h" | 5 #include "core/loader/ThreadableLoadingContext.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/TaskRunnerHelper.h" | 8 #include "core/dom/TaskRunnerHelper.h" |
9 #include "core/loader/WorkerFetchContext.h" | 9 #include "core/loader/WorkerFetchContext.h" |
10 #include "core/workers/WorkerGlobalScope.h" | 10 #include "core/workers/WorkerGlobalScope.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 DCHECK(IsContextThread()); | 45 DCHECK(IsContextThread()); |
46 return document_->UserAgent(); | 46 return document_->UserAgent(); |
47 } | 47 } |
48 | 48 |
49 Document* GetLoadingDocument() override { | 49 Document* GetLoadingDocument() override { |
50 DCHECK(IsContextThread()); | 50 DCHECK(IsContextThread()); |
51 return document_.Get(); | 51 return document_.Get(); |
52 } | 52 } |
53 | 53 |
54 RefPtr<WebTaskRunner> GetTaskRunner(TaskType type) override { | 54 RefPtr<WebTaskRunner> GetTaskRunner(TaskType type) override { |
| 55 DCHECK(IsContextThread()); |
55 return TaskRunnerHelper::Get(type, document_.Get()); | 56 return TaskRunnerHelper::Get(type, document_.Get()); |
56 } | 57 } |
57 | 58 |
58 void RecordUseCount(UseCounter::Feature feature) override { | 59 void RecordUseCount(UseCounter::Feature feature) override { |
59 UseCounter::Count(document_.Get(), feature); | 60 UseCounter::Count(document_.Get(), feature); |
60 } | 61 } |
61 | 62 |
62 DEFINE_INLINE_VIRTUAL_TRACE() { | 63 DEFINE_INLINE_VIRTUAL_TRACE() { |
63 visitor->Trace(document_); | 64 visitor->Trace(document_); |
64 ThreadableLoadingContext::Trace(visitor); | 65 ThreadableLoadingContext::Trace(visitor); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 106 } |
106 | 107 |
107 String UserAgent() const override { | 108 String UserAgent() const override { |
108 DCHECK(IsContextThread()); | 109 DCHECK(IsContextThread()); |
109 return worker_global_scope_->UserAgent(); | 110 return worker_global_scope_->UserAgent(); |
110 } | 111 } |
111 | 112 |
112 Document* GetLoadingDocument() override { return nullptr; } | 113 Document* GetLoadingDocument() override { return nullptr; } |
113 | 114 |
114 RefPtr<WebTaskRunner> GetTaskRunner(TaskType type) override { | 115 RefPtr<WebTaskRunner> GetTaskRunner(TaskType type) override { |
| 116 DCHECK(IsContextThread()); |
115 return fetch_context_->LoadingTaskRunner(); | 117 return fetch_context_->LoadingTaskRunner(); |
116 } | 118 } |
117 | 119 |
118 void RecordUseCount(UseCounter::Feature feature) override { | 120 void RecordUseCount(UseCounter::Feature feature) override { |
119 UseCounter::Count(worker_global_scope_, feature); | 121 UseCounter::Count(worker_global_scope_, feature); |
120 } | 122 } |
121 | 123 |
122 DEFINE_INLINE_VIRTUAL_TRACE() { | 124 DEFINE_INLINE_VIRTUAL_TRACE() { |
123 visitor->Trace(fetch_context_); | 125 visitor->Trace(fetch_context_); |
124 visitor->Trace(worker_global_scope_); | 126 visitor->Trace(worker_global_scope_); |
125 ThreadableLoadingContext::Trace(visitor); | 127 ThreadableLoadingContext::Trace(visitor); |
126 } | 128 } |
127 | 129 |
128 private: | 130 private: |
129 Member<WorkerGlobalScope> worker_global_scope_; | 131 Member<WorkerGlobalScope> worker_global_scope_; |
130 Member<WorkerFetchContext> fetch_context_; | 132 Member<WorkerFetchContext> fetch_context_; |
131 }; | 133 }; |
132 | 134 |
133 ThreadableLoadingContext* ThreadableLoadingContext::Create(Document& document) { | 135 ThreadableLoadingContext* ThreadableLoadingContext::Create(Document& document) { |
134 return new DocumentThreadableLoadingContext(document); | 136 return new DocumentThreadableLoadingContext(document); |
135 } | 137 } |
136 | 138 |
137 ThreadableLoadingContext* ThreadableLoadingContext::Create( | 139 ThreadableLoadingContext* ThreadableLoadingContext::Create( |
138 WorkerGlobalScope& worker_global_scope) { | 140 WorkerGlobalScope& worker_global_scope) { |
139 return new WorkerThreadableLoadingContext(worker_global_scope); | 141 return new WorkerThreadableLoadingContext(worker_global_scope); |
140 } | 142 } |
141 | 143 |
142 } // namespace blink | 144 } // namespace blink |
OLD | NEW |