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

Side by Side Diff: Source/core/inspector/InspectorApplicationCacheAgent.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) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 10 matching lines...) Expand all
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/inspector/InspectorApplicationCacheAgent.h" 27 #include "core/inspector/InspectorApplicationCacheAgent.h"
28 28
29 #include "core/frame/LocalFrame.h" 29 #include "core/frame/LocalFrame.h"
30 #include "core/inspector/InspectorIdentifiers.h" 30 #include "core/inspector/InspectorIdentifiers.h"
31 #include "core/inspector/InspectorPageAgent.h"
32 #include "core/inspector/InspectorState.h" 31 #include "core/inspector/InspectorState.h"
33 #include "core/inspector/InstrumentingAgents.h" 32 #include "core/inspector/InstrumentingAgents.h"
34 #include "core/loader/DocumentLoader.h" 33 #include "core/loader/DocumentLoader.h"
35 #include "core/loader/FrameLoader.h" 34 #include "core/loader/FrameLoader.h"
36 #include "core/page/NetworkStateNotifier.h" 35 #include "core/page/NetworkStateNotifier.h"
37 #include "wtf/text/StringBuilder.h" 36 #include "wtf/text/StringBuilder.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 namespace ApplicationCacheAgentState { 40 namespace ApplicationCacheAgentState {
42 static const char applicationCacheAgentEnabled[] = "applicationCacheAgentEnabled "; 41 static const char applicationCacheAgentEnabled[] = "applicationCacheAgentEnabled ";
43 } 42 }
44 43
45 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InspectorPageAgen t* pageAgent) 44 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(LocalFrame* inspe ctedFrame)
46 : InspectorBaseAgent<InspectorApplicationCacheAgent, InspectorFrontend::Appl icationCache>("ApplicationCache") 45 : InspectorBaseAgent<InspectorApplicationCacheAgent, InspectorFrontend::Appl icationCache>("ApplicationCache")
47 , m_pageAgent(pageAgent) 46 , m_inspectedFrame(inspectedFrame)
48 { 47 {
49 } 48 }
50 49
51 void InspectorApplicationCacheAgent::restore() 50 void InspectorApplicationCacheAgent::restore()
52 { 51 {
53 if (m_state->getBoolean(ApplicationCacheAgentState::applicationCacheAgentEna bled)) { 52 if (m_state->getBoolean(ApplicationCacheAgentState::applicationCacheAgentEna bled)) {
54 ErrorString error; 53 ErrorString error;
55 enable(&error); 54 enable(&error);
56 } 55 }
57 } 56 }
(...skipping 21 matching lines...) Expand all
79 ApplicationCacheHost::Status status = host->status(); 78 ApplicationCacheHost::Status status = host->status();
80 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); 79 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
81 80
82 String manifestURL = info.m_manifest.string(); 81 String manifestURL = info.m_manifest.string();
83 String frameId = InspectorIdentifiers<LocalFrame>::identifier(frame); 82 String frameId = InspectorIdentifiers<LocalFrame>::identifier(frame);
84 frontend()->applicationCacheStatusUpdated(frameId, manifestURL, static_cast< int>(status)); 83 frontend()->applicationCacheStatusUpdated(frameId, manifestURL, static_cast< int>(status));
85 } 84 }
86 85
87 void InspectorApplicationCacheAgent::networkStateChanged(LocalFrame* frame, bool online) 86 void InspectorApplicationCacheAgent::networkStateChanged(LocalFrame* frame, bool online)
88 { 87 {
89 if (frame == m_pageAgent->inspectedFrame()) 88 if (frame == m_inspectedFrame)
90 frontend()->networkStateUpdated(online); 89 frontend()->networkStateUpdated(online);
91 } 90 }
92 91
93 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr <TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest> >& result) 92 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr <TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest> >& result)
94 { 93 {
95 result = TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest >::create(); 94 result = TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest >::create();
96 95
97 LocalFrame* inspectedFrame = m_pageAgent->inspectedFrame(); 96 for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseN ext(m_inspectedFrame)) {
98 for (Frame* frame = inspectedFrame; frame; frame = frame->tree().traverseNex t(inspectedFrame)) {
99 if (!frame->isLocalFrame()) 97 if (!frame->isLocalFrame())
100 continue; 98 continue;
101 DocumentLoader* documentLoader = toLocalFrame(frame)->loader().documentL oader(); 99 DocumentLoader* documentLoader = toLocalFrame(frame)->loader().documentL oader();
102 if (!documentLoader) 100 if (!documentLoader)
103 continue; 101 continue;
104 102
105 ApplicationCacheHost* host = documentLoader->applicationCacheHost(); 103 ApplicationCacheHost* host = documentLoader->applicationCacheHost();
106 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); 104 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
107 String manifestURL = info.m_manifest.string(); 105 String manifestURL = info.m_manifest.string();
108 if (!manifestURL.isEmpty()) { 106 if (!manifestURL.isEmpty()) {
109 RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = Typ eBuilder::ApplicationCache::FrameWithManifest::create() 107 RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = Typ eBuilder::ApplicationCache::FrameWithManifest::create()
110 .setFrameId(InspectorIdentifiers<LocalFrame>::identifier(toLocal Frame(frame))) 108 .setFrameId(InspectorIdentifiers<LocalFrame>::identifier(toLocal Frame(frame)))
111 .setManifestURL(manifestURL) 109 .setManifestURL(manifestURL)
112 .setStatus(static_cast<int>(host->status())); 110 .setStatus(static_cast<int>(host->status()));
113 result->addItem(value); 111 result->addItem(value);
114 } 112 }
115 } 113 }
116 } 114 }
117 115
118 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(Er rorString* errorString, String frameId) 116 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(Er rorString* errorString, String frameId)
119 { 117 {
120 LocalFrame* frame = m_pageAgent->assertFrame(errorString, frameId); 118 LocalFrame* frame = InspectorIdentifiers<LocalFrame>::lookup(frameId);
121 if (!frame) 119 if (!frame || frame->instrumentingAgents() != m_inspectedFrame->instrumentin gAgents()) {
120 *errorString = "No frame for given id found";
122 return nullptr; 121 return nullptr;
123 122 }
124 return InspectorPageAgent::assertDocumentLoader(errorString, frame); 123 DocumentLoader* documentLoader = frame->loader().documentLoader();
124 if (!documentLoader) {
125 *errorString = "No documentLoader for given frame found";
126 return nullptr;
127 }
128 return documentLoader;
125 } 129 }
126 130
127 void InspectorApplicationCacheAgent::getManifestForFrame(ErrorString* errorStrin g, const String& frameId, String* manifestURL) 131 void InspectorApplicationCacheAgent::getManifestForFrame(ErrorString* errorStrin g, const String& frameId, String* manifestURL)
128 { 132 {
129 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId); 133 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId);
130 if (!documentLoader) 134 if (!documentLoader)
131 return; 135 return;
132 136
133 ApplicationCacheHost::CacheInfo info = documentLoader->applicationCacheHost( )->applicationCacheInfo(); 137 ApplicationCacheHost::CacheInfo info = documentLoader->applicationCacheHost( )->applicationCacheInfo();
134 *manifestURL = info.m_manifest.string(); 138 *manifestURL = info.m_manifest.string();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 196
193 RefPtr<TypeBuilder::ApplicationCache::ApplicationCacheResource> value = Type Builder::ApplicationCache::ApplicationCacheResource::create() 197 RefPtr<TypeBuilder::ApplicationCache::ApplicationCacheResource> value = Type Builder::ApplicationCache::ApplicationCacheResource::create()
194 .setUrl(resourceInfo.m_resource.string()) 198 .setUrl(resourceInfo.m_resource.string())
195 .setSize(static_cast<int>(resourceInfo.m_size)) 199 .setSize(static_cast<int>(resourceInfo.m_size))
196 .setType(builder.toString()); 200 .setType(builder.toString());
197 return value; 201 return value;
198 } 202 }
199 203
200 DEFINE_TRACE(InspectorApplicationCacheAgent) 204 DEFINE_TRACE(InspectorApplicationCacheAgent)
201 { 205 {
202 visitor->trace(m_pageAgent); 206 visitor->trace(m_inspectedFrame);
203 InspectorBaseAgent::trace(visitor); 207 InspectorBaseAgent::trace(visitor);
204 } 208 }
205 209
206 } // namespace blink 210 } // namespace blink
207 211
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698