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

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

Issue 1092123004: DevTools: remove dependency of most agents on InspectorPageAgent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: further cuts on InspectorPageAgent inter-agents API Created 5 years, 8 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 | Annotate | Revision Log
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled)) { 301 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled)) {
302 ErrorString error; 302 ErrorString error;
303 disable(&error); 303 disable(&error);
304 } 304 }
305 ASSERT(!m_instrumentingAgents->inspectorResourceAgent()); 305 ASSERT(!m_instrumentingAgents->inspectorResourceAgent());
306 #endif 306 #endif
307 } 307 }
308 308
309 DEFINE_TRACE(InspectorResourceAgent) 309 DEFINE_TRACE(InspectorResourceAgent)
310 { 310 {
311 visitor->trace(m_pageAgent); 311 visitor->trace(m_inspectedFrame);
312 #if ENABLE(OILPAN) 312 #if ENABLE(OILPAN)
313 visitor->trace(m_pendingXHRReplayData); 313 visitor->trace(m_pendingXHRReplayData);
314 visitor->trace(m_replayXHRs); 314 visitor->trace(m_replayXHRs);
315 visitor->trace(m_replayXHRsToBeDeleted); 315 visitor->trace(m_replayXHRsToBeDeleted);
316 #endif 316 #endif
317 InspectorBaseAgent::trace(visitor); 317 InspectorBaseAgent::trace(visitor);
318 } 318 }
319 319
320 void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL oader* loader, ResourceRequest& request, const ResourceResponse& redirectRespons e, const FetchInitiatorInfo& initiatorInfo) 320 void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL oader* loader, ResourceRequest& request, const ResourceResponse& redirectRespons e, const FetchInitiatorInfo& initiatorInfo)
321 { 321 {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 { 536 {
537 m_pendingXHRReplayData.remove(client); 537 m_pendingXHRReplayData.remove(client);
538 538
539 // See comments on |didFailXHRLoading| for why we are delaying delete. 539 // See comments on |didFailXHRLoading| for why we are delaying delete.
540 delayedRemoveReplayXHR(xhr); 540 delayedRemoveReplayXHR(xhr);
541 541
542 if (m_state->getBoolean(ResourceAgentState::monitoringXHR)) { 542 if (m_state->getBoolean(ResourceAgentState::monitoringXHR)) {
543 String message = "XHR finished loading: " + method + " \"" + url + "\"." ; 543 String message = "XHR finished loading: " + method + " \"" + url + "\"." ;
544 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea te(NetworkMessageSource, DebugMessageLevel, message); 544 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea te(NetworkMessageSource, DebugMessageLevel, message);
545 consoleMessage->setRequestIdentifier(identifier); 545 consoleMessage->setRequestIdentifier(identifier);
546 m_pageAgent->frameHost()->consoleMessageStorage().reportMessage(context, consoleMessage.release()); 546 m_inspectedFrame->host()->consoleMessageStorage().reportMessage(context, consoleMessage.release());
547 } 547 }
548 } 548 }
549 549
550 void InspectorResourceAgent::willSendEventSourceRequest(ThreadableLoaderClient* eventSource) 550 void InspectorResourceAgent::willSendEventSourceRequest(ThreadableLoaderClient* eventSource)
551 { 551 {
552 m_pendingEventSource = eventSource; 552 m_pendingEventSource = eventSource;
553 } 553 }
554 554
555 void InspectorResourceAgent::willDispachEventSourceEvent(ThreadableLoaderClient* eventSource, const AtomicString& eventName, const AtomicString& eventId, const Vector<UChar>& data) 555 void InspectorResourceAgent::willDispachEventSourceEvent(ThreadableLoaderClient* eventSource, const AtomicString& eventName, const AtomicString& eventId, const Vector<UChar>& data)
556 { 556 {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 { 728 {
729 m_state->setObject(ResourceAgentState::extraRequestHeaders, headers); 729 m_state->setObject(ResourceAgentState::extraRequestHeaders, headers);
730 } 730 }
731 731
732 bool InspectorResourceAgent::getResponseBodyBlob(const String& requestId, PassRe fPtrWillBeRawPtr<GetResponseBodyCallback> callback) 732 bool InspectorResourceAgent::getResponseBodyBlob(const String& requestId, PassRe fPtrWillBeRawPtr<GetResponseBodyCallback> callback)
733 { 733 {
734 NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->da ta(requestId); 734 NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->da ta(requestId);
735 if (!resourceData) 735 if (!resourceData)
736 return false; 736 return false;
737 if (BlobDataHandle* blob = resourceData->downloadedFileBlob()) { 737 if (BlobDataHandle* blob = resourceData->downloadedFileBlob()) {
738 if (LocalFrame* frame = m_pageAgent->frameForId(resourceData->frameId()) ) { 738 LocalFrame* frame = InspectorIdentifiers<LocalFrame>::lookup(resourceDat a->frameId());
739 if (frame && frame->instrumentingAgents() == m_inspectedFrame->instrumen tingAgents()) {
739 if (Document* document = frame->document()) { 740 if (Document* document = frame->document()) {
740 InspectorFileReaderLoaderClient* client = new InspectorFileReade rLoaderClient(blob, InspectorPageAgent::createResourceTextDecoder(resourceData-> mimeType(), resourceData->textEncodingName()), callback); 741 InspectorFileReaderLoaderClient* client = new InspectorFileReade rLoaderClient(blob, InspectorPageAgent::createResourceTextDecoder(resourceData-> mimeType(), resourceData->textEncodingName()), callback);
741 client->start(document); 742 client->start(document);
742 return true; 743 return true;
743 } 744 }
744 } 745 }
745 } 746 }
746 return false; 747 return false;
747 } 748 }
748 749
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 void InspectorResourceAgent::canClearBrowserCookies(ErrorString*, bool* result) 835 void InspectorResourceAgent::canClearBrowserCookies(ErrorString*, bool* result)
835 { 836 {
836 *result = true; 837 *result = true;
837 } 838 }
838 839
839 void InspectorResourceAgent::setCacheDisabled(ErrorString*, bool cacheDisabled) 840 void InspectorResourceAgent::setCacheDisabled(ErrorString*, bool cacheDisabled)
840 { 841 {
841 m_state->setBoolean(ResourceAgentState::cacheDisabled, cacheDisabled); 842 m_state->setBoolean(ResourceAgentState::cacheDisabled, cacheDisabled);
842 if (cacheDisabled) 843 if (cacheDisabled)
843 memoryCache()->evictResources(); 844 memoryCache()->evictResources();
844 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre e().traverseNext()) { 845 for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseN ext(m_inspectedFrame)) {
845 if (frame->isLocalFrame()) 846 if (frame->isLocalFrame())
846 toLocalFrame(frame)->document()->fetcher()->garbageCollectDocumentRe sources(); 847 toLocalFrame(frame)->document()->fetcher()->garbageCollectDocumentRe sources();
847 } 848 }
848 } 849 }
849 850
850 void InspectorResourceAgent::emulateNetworkConditions(ErrorString*, bool, double , double, double) 851 void InspectorResourceAgent::emulateNetworkConditions(ErrorString*, bool, double , double, double)
851 { 852 {
852 } 853 }
853 854
854 void InspectorResourceAgent::setDataSizeLimitsForTest(ErrorString*, int maxTotal , int maxResource) 855 void InspectorResourceAgent::setDataSizeLimitsForTest(ErrorString*, int maxTotal , int maxResource)
855 { 856 {
856 m_resourcesData->setResourcesDataSizeLimits(maxTotal, maxResource); 857 m_resourcesData->setResourcesDataSizeLimits(maxTotal, maxResource);
857 } 858 }
858 859
859 void InspectorResourceAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* lo ader) 860 void InspectorResourceAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* lo ader)
860 { 861 {
861 if (loader->frame() != m_pageAgent->inspectedFrame()) 862 if (loader->frame() != m_inspectedFrame)
862 return; 863 return;
863 864
864 if (m_state->getBoolean(ResourceAgentState::cacheDisabled)) 865 if (m_state->getBoolean(ResourceAgentState::cacheDisabled))
865 memoryCache()->evictResources(); 866 memoryCache()->evictResources();
866 867
867 m_resourcesData->clear(InspectorIdentifiers<DocumentLoader>::identifier(load er)); 868 m_resourcesData->clear(InspectorIdentifiers<DocumentLoader>::identifier(load er));
868 } 869 }
869 870
870 void InspectorResourceAgent::frameScheduledNavigation(LocalFrame* frame, double) 871 void InspectorResourceAgent::frameScheduledNavigation(LocalFrame* frame, double)
871 { 872 {
(...skipping 29 matching lines...) Expand all
901 } 902 }
902 } 903 }
903 return false; 904 return false;
904 } 905 }
905 906
906 void InspectorResourceAgent::removeFinishedReplayXHRFired(Timer<InspectorResourc eAgent>*) 907 void InspectorResourceAgent::removeFinishedReplayXHRFired(Timer<InspectorResourc eAgent>*)
907 { 908 {
908 m_replayXHRsToBeDeleted.clear(); 909 m_replayXHRsToBeDeleted.clear();
909 } 910 }
910 911
911 InspectorResourceAgent::InspectorResourceAgent(InspectorPageAgent* pageAgent) 912 InspectorResourceAgent::InspectorResourceAgent(LocalFrame* inspectedFrame)
912 : InspectorBaseAgent<InspectorResourceAgent, InspectorFrontend::Network>("Ne twork") 913 : InspectorBaseAgent<InspectorResourceAgent, InspectorFrontend::Network>("Ne twork")
913 , m_pageAgent(pageAgent) 914 , m_inspectedFrame(inspectedFrame)
914 , m_resourcesData(adoptPtr(new NetworkResourcesData())) 915 , m_resourcesData(adoptPtr(new NetworkResourcesData()))
915 , m_pendingEventSource(nullptr) 916 , m_pendingEventSource(nullptr)
916 , m_isRecalculatingStyle(false) 917 , m_isRecalculatingStyle(false)
917 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) 918 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired)
918 { 919 {
919 } 920 }
920 921
921 bool InspectorResourceAgent::shouldForceCORSPreflight() 922 bool InspectorResourceAgent::shouldForceCORSPreflight()
922 { 923 {
923 return m_state->getBoolean(ResourceAgentState::cacheDisabled); 924 return m_state->getBoolean(ResourceAgentState::cacheDisabled);
924 } 925 }
925 926
926 } // namespace blink 927 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698