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

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

Issue 2545023002: Clean up around FrameFetchContext (Closed)
Patch Set: Rebase Created 4 years 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/FrameFetchContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
index 049c2e27133a05c7fed4fc1962116c16e9474ea6..d5787a37460e685c718a241b8f37bfc1dfa88601 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -203,12 +203,20 @@ FrameFetchContext::~FrameFetchContext() {
m_documentLoader = nullptr;
}
+LocalFrame* FrameFetchContext::frameOfImportsController() const {
+ DCHECK(m_document);
+ HTMLImportsController* importsController = m_document->importsController();
+ DCHECK(importsController);
+ LocalFrame* frame = importsController->master()->frame();
+ DCHECK(frame);
+ return frame;
+}
+
LocalFrame* FrameFetchContext::frame() const {
- LocalFrame* frame = nullptr;
- if (m_documentLoader)
- frame = m_documentLoader->frame();
- else if (m_document && m_document->importsController())
- frame = m_document->importsController()->master()->frame();
+ if (!m_documentLoader)
+ return frameOfImportsController();
+
+ LocalFrame* frame = m_documentLoader->frame();
DCHECK(frame);
return frame;
}
@@ -357,8 +365,10 @@ WebCachePolicy FrameFetchContext::resourceRequestCachePolicy(
// FIXME(http://crbug.com/274173): This means Inspector, which uses
// DocumentLoader as a grouping entity, cannot see imported documents.
inline DocumentLoader* FrameFetchContext::masterDocumentLoader() const {
- return m_documentLoader ? m_documentLoader.get()
- : frame()->loader().documentLoader();
+ if (m_documentLoader)
+ return m_documentLoader.get();
+
+ return frameOfImportsController()->loader().documentLoader();
}
void FrameFetchContext::dispatchDidChangeResourcePriority(
@@ -491,9 +501,11 @@ void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(
bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const {
if (!m_documentLoader)
return true;
+
+ FrameLoader& loader = m_documentLoader->frame()->loader();
if (type == Resource::MainResource)
- return m_documentLoader == frame()->loader().provisionalDocumentLoader();
- return m_documentLoader == frame()->loader().documentLoader();
+ return m_documentLoader == loader.provisionalDocumentLoader();
+ return m_documentLoader == loader.documentLoader();
}
static std::unique_ptr<TracedValue>
@@ -767,8 +779,10 @@ bool FrameFetchContext::isControlledByServiceWorker() const {
return false;
if (m_documentLoader) {
- return frame()->loader().client()->isControlledByServiceWorker(
- *m_documentLoader);
+ return m_documentLoader->frame()
+ ->loader()
+ .client()
+ ->isControlledByServiceWorker(*m_documentLoader);
}
// m_documentLoader is null while loading resources from an HTML import. In
// such cases whether the request is controlled by ServiceWorker or not is
@@ -779,8 +793,10 @@ bool FrameFetchContext::isControlledByServiceWorker() const {
int64_t FrameFetchContext::serviceWorkerID() const {
DCHECK(m_documentLoader || frame()->loader().documentLoader());
- if (m_documentLoader)
- return frame()->loader().client()->serviceWorkerID(*m_documentLoader);
+ if (m_documentLoader) {
+ return m_documentLoader->frame()->loader().client()->serviceWorkerID(
+ *m_documentLoader);
+ }
// m_documentLoader is null while loading resources from an HTML import.
// In such cases a service worker ID could be retrieved from the document
// loader of the frame.
@@ -975,7 +991,8 @@ void FrameFetchContext::dispatchDidReceiveResponseInternal(
MixedContentChecker::checkMixedPrivatePublic(frame(),
response.remoteIPAddress());
if (m_documentLoader &&
- m_documentLoader == frame()->loader().provisionalDocumentLoader()) {
+ m_documentLoader ==
+ m_documentLoader->frame()->loader().provisionalDocumentLoader()) {
ResourceFetcher* fetcher = nullptr;
if (frame()->document())
fetcher = frame()->document()->fetcher();
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.h ('k') | third_party/WebKit/Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698