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

Side by Side 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, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/loader/ThreadableLoadingContext.h"
6
7 #include "core/dom/Document.h"
8 #include "core/dom/TaskRunnerHelper.h"
9 #include "platform/loader/fetch/ResourceFetcher.h"
10
11 namespace blink {
12
13 class DocumentThreadableLoadingContext final : public ThreadableLoadingContext {
14 public:
15 explicit DocumentThreadableLoadingContext(Document& document)
16 : m_document(&document) {}
17
18 ~DocumentThreadableLoadingContext() override = default;
19
20 bool isContextThread() const override {
21 return m_document->isContextThread();
22 }
23
24 ResourceFetcher* getResourceFetcher() override {
25 DCHECK(isContextThread());
26 return m_document->fetcher();
27 }
28
29 SecurityOrigin* getSecurityOrigin() override {
30 DCHECK(isContextThread());
31 return m_document->getSecurityOrigin();
32 }
33
34 bool isSecureContext() const override {
35 DCHECK(isContextThread());
36 return m_document->isSecureContext();
37 }
38
39 KURL firstPartyForCookies() const override {
40 DCHECK(isContextThread());
41 return m_document->firstPartyForCookies();
42 }
43
44 String userAgent() const override {
45 DCHECK(isContextThread());
46 return m_document->userAgent();
47 }
48
49 Document* getLoadingDocument() override {
50 DCHECK(isContextThread());
51 return m_document.get();
52 }
53
54 RefPtr<WebTaskRunner> getTaskRunner(TaskType type) override {
55 return TaskRunnerHelper::get(type, m_document.get());
56 }
57
58 void recordUseCount(UseCounter::Feature feature) override {
59 UseCounter::count(m_document.get(), feature);
60 }
61
62 DEFINE_INLINE_VIRTUAL_TRACE() {
63 visitor->trace(m_document);
64 ThreadableLoadingContext::trace(visitor);
65 }
66
67 private:
68 Member<Document> m_document;
69 };
70
71 ThreadableLoadingContext* ThreadableLoadingContext::create(Document& document) {
72 // For now this is the only default implementation.
73 return new DocumentThreadableLoadingContext(document);
74 }
75
76 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698