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

Unified Diff: Source/core/inspector/InspectorResourceContentLoader.cpp

Issue 338253007: Revert "DevTools: Load document (html) content from disk cache in page agent enabling." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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
« no previous file with comments | « Source/core/inspector/InspectorResourceContentLoader.h ('k') | Source/core/loader/FrameLoader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorResourceContentLoader.cpp
diff --git a/Source/core/inspector/InspectorResourceContentLoader.cpp b/Source/core/inspector/InspectorResourceContentLoader.cpp
deleted file mode 100644
index 7590581b6a5c57f52331f21ee927e695f3591ee6..0000000000000000000000000000000000000000
--- a/Source/core/inspector/InspectorResourceContentLoader.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2014 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 "config.h"
-#include "core/inspector/InspectorResourceContentLoader.h"
-
-#include "FetchInitiatorTypeNames.h"
-#include "core/css/CSSStyleSheet.h"
-#include "core/css/StyleSheetContents.h"
-#include "core/fetch/CSSStyleSheetResource.h"
-#include "core/fetch/Resource.h"
-#include "core/fetch/ResourceFetcher.h"
-#include "core/fetch/ResourcePtr.h"
-#include "core/fetch/StyleSheetResourceClient.h"
-#include "core/frame/LocalFrame.h"
-#include "core/html/VoidCallback.h"
-#include "core/inspector/InspectorCSSAgent.h"
-#include "core/inspector/InspectorPageAgent.h"
-#include "core/page/Page.h"
-
-namespace WebCore {
-
-InspectorResourceContentLoader::InspectorResourceContentLoader(Page* page)
- : m_allRequestsStarted(false)
-{
- Vector<Document*> documents;
- for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (!frame->isLocalFrame())
- continue;
- LocalFrame* localFrame = toLocalFrame(frame);
- documents.append(localFrame->document());
- documents.appendVector(InspectorPageAgent::importsForFrame(localFrame));
- }
- for (Vector<Document*>::const_iterator it = documents.begin(); it != documents.end(); ++it) {
- HashSet<String> urlsToFetch;
- Document* document = *it;
- ResourceRequest resourceRequest;
-
- if (!document->frame() || !document->frame()->loader().requestFromHistoryForInspector(ReturnCacheDataDontLoad, &resourceRequest)) {
- resourceRequest = document->url();
- resourceRequest.setCachePolicy(ReturnCacheDataDontLoad);
- }
-
- if (!resourceRequest.url().string().isEmpty()) {
- urlsToFetch.add(resourceRequest.url().string());
- FetchRequest request(resourceRequest, FetchInitiatorTypeNames::internal);
- ResourcePtr<Resource> resource = document->fetcher()->fetchRawResource(request);
- // Prevent garbage collection by holding a reference to this resource.
- m_pendingResources.add(resource.get());
- m_resources.append(resource.get());
- resource->addClient(static_cast<RawResourceClient*>(this));
- }
-
- Vector<CSSStyleSheet*> styleSheets;
- InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets);
- for (Vector<CSSStyleSheet*>::const_iterator it2 = styleSheets.begin(); it2 != styleSheets.end(); ++it2) {
- CSSStyleSheet* styleSheet = *it2;
- if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted())
- continue;
- String url = styleSheet->contents()->baseURL().string();
- if (url.isEmpty() || urlsToFetch.contains(url))
- continue;
- urlsToFetch.add(url);
- FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::internal);
- ResourcePtr<Resource> resource = document->fetcher()->fetchCSSStyleSheet(request);
- // Prevent garbage collection by holding a reference to this resource.
- if (m_pendingResources.contains(resource.get()))
- continue;
- m_pendingResources.add(resource.get());
- m_resources.append(resource.get());
- resource->addClient(static_cast<StyleSheetResourceClient*>(this));
- }
- }
-
- m_allRequestsStarted = true;
- checkDone();
-}
-
-void InspectorResourceContentLoader::addListener(PassOwnPtr<VoidCallback> callback)
-{
- m_callbacks.append(callback);
- checkDone();
-}
-
-InspectorResourceContentLoader::~InspectorResourceContentLoader()
-{
- stop();
-}
-
-void InspectorResourceContentLoader::stop()
-{
- HashSet<Resource*> pendingResources;
- m_pendingResources.swap(pendingResources);
- for (HashSet<Resource*>::const_iterator it = pendingResources.begin(); it != pendingResources.end(); ++it)
- removeAsClientFromResource(*it);
- // Make sure all callbacks are called to prevent infinite waiting time.
- checkDone();
-}
-
-void InspectorResourceContentLoader::removeAsClientFromResource(Resource* resource)
-{
- if (resource->type() == Resource::Raw)
- resource->removeClient(static_cast<RawResourceClient*>(this));
- else
- resource->removeClient(static_cast<StyleSheetResourceClient*>(this));
-}
-
-bool InspectorResourceContentLoader::hasFinished()
-{
- return m_allRequestsStarted && m_pendingResources.size() == 0;
-}
-
-void InspectorResourceContentLoader::checkDone()
-{
- if (!hasFinished())
- return;
- Vector<OwnPtr<VoidCallback> > callbacks;
- callbacks.swap(m_callbacks);
- for (Vector<OwnPtr<VoidCallback> >::const_iterator it = callbacks.begin(); it != callbacks.end(); ++it)
- (*it)->handleEvent();
-}
-
-void InspectorResourceContentLoader::notifyFinished(Resource* resource)
-{
- if (resource->type() == Resource::CSSStyleSheet)
- return;
- resourceFinished(resource);
-}
-
-void InspectorResourceContentLoader::setCSSStyleSheet(const String&, const KURL&, const String&, const CSSStyleSheetResource* resource)
-{
- resourceFinished(const_cast<CSSStyleSheetResource*>(resource));
-}
-
-void InspectorResourceContentLoader::resourceFinished(Resource* resource)
-{
- m_pendingResources.remove(resource);
- removeAsClientFromResource(resource);
- checkDone();
-}
-
-} // namespace WebCore
« no previous file with comments | « Source/core/inspector/InspectorResourceContentLoader.h ('k') | Source/core/loader/FrameLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698