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

Side by Side Diff: Source/core/inspector/InspectorResourceAgent.cpp

Issue 640463003: MemoryCache: Enable MemoryCache to have multiple isolated resource maps (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tweak variable names Created 6 years, 1 month 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
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.cpp ('k') | Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 return; 732 return;
733 733
734 ExecutionContext* executionContext = xhrReplayData->executionContext(); 734 ExecutionContext* executionContext = xhrReplayData->executionContext();
735 if (!executionContext) { 735 if (!executionContext) {
736 m_resourcesData->setXHRReplayData(requestId, 0); 736 m_resourcesData->setXHRReplayData(requestId, 0);
737 return; 737 return;
738 } 738 }
739 739
740 RefPtrWillBeRawPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(executionCon text); 740 RefPtrWillBeRawPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(executionCon text);
741 741
742 Resource* cachedResource = memoryCache()->resourceForURL(xhrReplayData->url( )); 742 memoryCache()->removeURLFromCache(executionContext, xhrReplayData->url());
743 if (cachedResource)
744 memoryCache()->remove(cachedResource);
745 743
746 xhr->open(xhrReplayData->method(), xhrReplayData->url(), xhrReplayData->asyn c(), IGNORE_EXCEPTION); 744 xhr->open(xhrReplayData->method(), xhrReplayData->url(), xhrReplayData->asyn c(), IGNORE_EXCEPTION);
747 HTTPHeaderMap::const_iterator end = xhrReplayData->headers().end(); 745 HTTPHeaderMap::const_iterator end = xhrReplayData->headers().end();
748 for (HTTPHeaderMap::const_iterator it = xhrReplayData->headers().begin(); it != end; ++it) 746 for (HTTPHeaderMap::const_iterator it = xhrReplayData->headers().begin(); it != end; ++it)
749 xhr->setRequestHeader(it->key, it->value, IGNORE_EXCEPTION); 747 xhr->setRequestHeader(it->key, it->value, IGNORE_EXCEPTION);
750 xhr->sendForInspectorXHRReplay(xhrReplayData->formData(), IGNORE_EXCEPTION); 748 xhr->sendForInspectorXHRReplay(xhrReplayData->formData(), IGNORE_EXCEPTION);
751 749
752 m_replayXHRs.add(xhr); 750 m_replayXHRs.add(xhr);
753 } 751 }
754 752
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 void InspectorResourceAgent::setHostId(const String& hostId) 848 void InspectorResourceAgent::setHostId(const String& hostId)
851 { 849 {
852 m_hostId = hostId; 850 m_hostId = hostId;
853 } 851 }
854 852
855 bool InspectorResourceAgent::fetchResourceContent(Document* document, const KURL & url, String* content, bool* base64Encoded) 853 bool InspectorResourceAgent::fetchResourceContent(Document* document, const KURL & url, String* content, bool* base64Encoded)
856 { 854 {
857 // First try to fetch content from the cached resource. 855 // First try to fetch content from the cached resource.
858 Resource* cachedResource = document->fetcher()->cachedResource(url); 856 Resource* cachedResource = document->fetcher()->cachedResource(url);
859 if (!cachedResource) 857 if (!cachedResource)
860 cachedResource = memoryCache()->resourceForURL(url); 858 cachedResource = memoryCache()->resourceForURL(url, document->fetcher()- >getCacheIdentifier());
861 if (cachedResource && InspectorPageAgent::cachedResourceContent(cachedResour ce, content, base64Encoded)) 859 if (cachedResource && InspectorPageAgent::cachedResourceContent(cachedResour ce, content, base64Encoded))
862 return true; 860 return true;
863 861
864 // Then fall back to resource data. 862 // Then fall back to resource data.
865 Vector<NetworkResourcesData::ResourceData*> resources = m_resourcesData->res ources(); 863 Vector<NetworkResourcesData::ResourceData*> resources = m_resourcesData->res ources();
866 for (Vector<NetworkResourcesData::ResourceData*>::iterator it = resources.be gin(); it != resources.end(); ++it) { 864 for (Vector<NetworkResourcesData::ResourceData*>::iterator it = resources.be gin(); it != resources.end(); ++it) {
867 if ((*it)->url() == url) { 865 if ((*it)->url() == url) {
868 *content = (*it)->content(); 866 *content = (*it)->content();
869 *base64Encoded = (*it)->base64Encoded(); 867 *base64Encoded = (*it)->base64Encoded();
870 return true; 868 return true;
(...skipping 16 matching lines...) Expand all
887 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) 885 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired)
888 { 886 {
889 } 887 }
890 888
891 bool InspectorResourceAgent::shouldForceCORSPreflight() 889 bool InspectorResourceAgent::shouldForceCORSPreflight()
892 { 890 {
893 return m_state->getBoolean(ResourceAgentState::cacheDisabled); 891 return m_state->getBoolean(ResourceAgentState::cacheDisabled);
894 } 892 }
895 893
896 } // namespace blink 894 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.cpp ('k') | Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698