| OLD | NEW |
| (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/LoadingContext.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 DocumentLoadingContext : public LoadingContext { |
| 14 public: |
| 15 explicit DocumentLoadingContext(Document& document) : m_document(&document) {} |
| 16 |
| 17 ~DocumentLoadingContext() override = default; |
| 18 |
| 19 bool isContextThread() const override { |
| 20 return m_document->isContextThread(); |
| 21 } |
| 22 |
| 23 ResourceFetcher* getResourceFetcher() override { |
| 24 DCHECK(isContextThread()); |
| 25 return m_document->fetcher(); |
| 26 } |
| 27 |
| 28 SecurityOrigin* getSecurityOrigin() override { |
| 29 DCHECK(isContextThread()); |
| 30 return m_document->getSecurityOrigin(); |
| 31 } |
| 32 |
| 33 bool isSecureContext() const override { |
| 34 DCHECK(isContextThread()); |
| 35 return m_document->isSecureContext(); |
| 36 } |
| 37 |
| 38 KURL firstPartyForCookies() const override { |
| 39 DCHECK(isContextThread()); |
| 40 return m_document->firstPartyForCookies(); |
| 41 } |
| 42 |
| 43 String userAgent() const override { |
| 44 DCHECK(isContextThread()); |
| 45 return m_document->userAgent(); |
| 46 } |
| 47 |
| 48 Document* getLoadingDocument() override { |
| 49 DCHECK(isContextThread()); |
| 50 return m_document.get(); |
| 51 } |
| 52 |
| 53 RefPtr<WebTaskRunner> getTaskRunner(TaskType type) override { |
| 54 return TaskRunnerHelper::get(type, m_document.get()); |
| 55 } |
| 56 |
| 57 void recordUseCount(UseCounter::Feature feature) override { |
| 58 UseCounter::count(m_document.get(), feature); |
| 59 } |
| 60 |
| 61 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 62 visitor->trace(m_document); |
| 63 LoadingContext::trace(visitor); |
| 64 } |
| 65 |
| 66 private: |
| 67 Member<Document> m_document; |
| 68 }; |
| 69 |
| 70 LoadingContext* LoadingContext::create(Document& document) { |
| 71 // For now this is the only default implementation. |
| 72 return new DocumentLoadingContext(document); |
| 73 } |
| 74 |
| 75 } // namespace blink |
| OLD | NEW |