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

Unified Diff: third_party/WebKit/Source/core/loader/LoadingContext.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/LoadingContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/LoadingContext.cpp b/third_party/WebKit/Source/core/loader/LoadingContext.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2ea1a7ba18771a07a04594529645bab2a48121aa
--- /dev/null
+++ b/third_party/WebKit/Source/core/loader/LoadingContext.cpp
@@ -0,0 +1,75 @@
+// 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/LoadingContext.h"
+
+#include "core/dom/Document.h"
+#include "core/dom/TaskRunnerHelper.h"
+#include "platform/loader/fetch/ResourceFetcher.h"
+
+namespace blink {
+
+class DocumentLoadingContext : public LoadingContext {
yhirano 2017/03/01 03:41:34 +final
kinuko 2017/03/01 15:08:29 Done.
+ public:
+ explicit DocumentLoadingContext(Document& document) : m_document(&document) {}
+
+ ~DocumentLoadingContext() 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);
+ LoadingContext::trace(visitor);
+ }
+
+ private:
+ Member<Document> m_document;
+};
+
+LoadingContext* LoadingContext::create(Document& document) {
+ // For now this is the only default implementation.
+ return new DocumentLoadingContext(document);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698