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

Unified Diff: third_party/WebKit/Source/core/loader/ThreadableLoadingContext.cpp

Issue 2715803004: Introduce ThreadableLoadingContext: make threaded loading code one step away from Document (Closed)
Patch Set: . Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/ThreadableLoadingContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/ThreadableLoadingContext.cpp b/third_party/WebKit/Source/core/loader/ThreadableLoadingContext.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eb485861ba5974f1ce2d9344f16190e81aea1e34
--- /dev/null
+++ b/third_party/WebKit/Source/core/loader/ThreadableLoadingContext.cpp
@@ -0,0 +1,76 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/loader/ThreadableLoadingContext.h"
+
+#include "core/dom/Document.h"
+#include "core/dom/TaskRunnerHelper.h"
+#include "platform/loader/fetch/ResourceFetcher.h"
+
+namespace blink {
+
+class DocumentThreadableLoadingContext final : public ThreadableLoadingContext {
+ public:
+ explicit DocumentThreadableLoadingContext(Document& document)
+ : m_document(&document) {}
+
+ ~DocumentThreadableLoadingContext() override = default;
+
+ bool isContextThread() const override {
+ return m_document->isContextThread();
+ }
+
+ ResourceFetcher* getResourceFetcher() override {
+ DCHECK(isContextThread());
+ return m_document->fetcher();
+ }
+
+ SecurityOrigin* getSecurityOrigin() override {
+ DCHECK(isContextThread());
+ return m_document->getSecurityOrigin();
+ }
+
+ bool isSecureContext() const override {
+ DCHECK(isContextThread());
+ return m_document->isSecureContext();
+ }
+
+ KURL firstPartyForCookies() const override {
+ DCHECK(isContextThread());
+ return m_document->firstPartyForCookies();
+ }
+
+ String userAgent() const override {
+ DCHECK(isContextThread());
+ return m_document->userAgent();
+ }
+
+ Document* getLoadingDocument() override {
+ DCHECK(isContextThread());
+ return m_document.get();
+ }
+
+ RefPtr<WebTaskRunner> getTaskRunner(TaskType type) override {
+ return TaskRunnerHelper::get(type, m_document.get());
+ }
+
+ void recordUseCount(UseCounter::Feature feature) override {
+ UseCounter::count(m_document.get(), feature);
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE() {
+ visitor->trace(m_document);
+ ThreadableLoadingContext::trace(visitor);
+ }
+
+ private:
+ Member<Document> m_document;
+};
+
+ThreadableLoadingContext* ThreadableLoadingContext::create(Document& document) {
+ // For now this is the only default implementation.
+ return new DocumentThreadableLoadingContext(document);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698