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

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

Issue 1118963002: Revert of DevTools: remove dependency of most agents on InspectorPageAgent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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/InspectorResolver.h" 31 #include "core/inspector/InspectorPageAgent.h"
32 #include "core/inspector/InspectorState.h" 32 #include "core/inspector/InspectorState.h"
33 #include "core/inspector/InstrumentingAgents.h" 33 #include "core/inspector/InstrumentingAgents.h"
34 #include "core/loader/DocumentLoader.h" 34 #include "core/loader/DocumentLoader.h"
35 #include "core/loader/FrameLoader.h" 35 #include "core/loader/FrameLoader.h"
36 #include "core/page/NetworkStateNotifier.h" 36 #include "core/page/NetworkStateNotifier.h"
37 #include "wtf/text/StringBuilder.h" 37 #include "wtf/text/StringBuilder.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 namespace ApplicationCacheAgentState { 41 namespace ApplicationCacheAgentState {
42 static const char applicationCacheAgentEnabled[] = "applicationCacheAgentEnabled "; 42 static const char applicationCacheAgentEnabled[] = "applicationCacheAgentEnabled ";
43 } 43 }
44 44
45 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(LocalFrame* inspe ctedFrame) 45 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InspectorPageAgen t* pageAgent)
46 : InspectorBaseAgent<InspectorApplicationCacheAgent, InspectorFrontend::Appl icationCache>("ApplicationCache") 46 : InspectorBaseAgent<InspectorApplicationCacheAgent, InspectorFrontend::Appl icationCache>("ApplicationCache")
47 , m_inspectedFrame(inspectedFrame) 47 , m_pageAgent(pageAgent)
48 { 48 {
49 } 49 }
50 50
51 void InspectorApplicationCacheAgent::restore() 51 void InspectorApplicationCacheAgent::restore()
52 { 52 {
53 if (m_state->getBoolean(ApplicationCacheAgentState::applicationCacheAgentEna bled)) { 53 if (m_state->getBoolean(ApplicationCacheAgentState::applicationCacheAgentEna bled)) {
54 ErrorString error; 54 ErrorString error;
55 enable(&error); 55 enable(&error);
56 } 56 }
57 } 57 }
(...skipping 21 matching lines...) Expand all
79 ApplicationCacheHost::Status status = host->status(); 79 ApplicationCacheHost::Status status = host->status();
80 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); 80 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
81 81
82 String manifestURL = info.m_manifest.string(); 82 String manifestURL = info.m_manifest.string();
83 String frameId = InspectorIdentifiers<LocalFrame>::identifier(frame); 83 String frameId = InspectorIdentifiers<LocalFrame>::identifier(frame);
84 frontend()->applicationCacheStatusUpdated(frameId, manifestURL, static_cast< int>(status)); 84 frontend()->applicationCacheStatusUpdated(frameId, manifestURL, static_cast< int>(status));
85 } 85 }
86 86
87 void InspectorApplicationCacheAgent::networkStateChanged(LocalFrame* frame, bool online) 87 void InspectorApplicationCacheAgent::networkStateChanged(LocalFrame* frame, bool online)
88 { 88 {
89 if (frame == m_inspectedFrame) 89 if (frame == m_pageAgent->inspectedFrame())
90 frontend()->networkStateUpdated(online); 90 frontend()->networkStateUpdated(online);
91 } 91 }
92 92
93 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr <TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest> >& result) 93 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr <TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest> >& result)
94 { 94 {
95 result = TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest >::create(); 95 result = TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest >::create();
96 96
97 for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseN ext(m_inspectedFrame)) { 97 LocalFrame* inspectedFrame = m_pageAgent->inspectedFrame();
98 for (Frame* frame = inspectedFrame; frame; frame = frame->tree().traverseNex t(inspectedFrame)) {
98 if (!frame->isLocalFrame()) 99 if (!frame->isLocalFrame())
99 continue; 100 continue;
100 DocumentLoader* documentLoader = toLocalFrame(frame)->loader().documentL oader(); 101 DocumentLoader* documentLoader = toLocalFrame(frame)->loader().documentL oader();
101 if (!documentLoader) 102 if (!documentLoader)
102 continue; 103 continue;
103 104
104 ApplicationCacheHost* host = documentLoader->applicationCacheHost(); 105 ApplicationCacheHost* host = documentLoader->applicationCacheHost();
105 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); 106 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
106 String manifestURL = info.m_manifest.string(); 107 String manifestURL = info.m_manifest.string();
107 if (!manifestURL.isEmpty()) { 108 if (!manifestURL.isEmpty()) {
108 RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = Typ eBuilder::ApplicationCache::FrameWithManifest::create() 109 RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = Typ eBuilder::ApplicationCache::FrameWithManifest::create()
109 .setFrameId(InspectorIdentifiers<LocalFrame>::identifier(toLocal Frame(frame))) 110 .setFrameId(InspectorIdentifiers<LocalFrame>::identifier(toLocal Frame(frame)))
110 .setManifestURL(manifestURL) 111 .setManifestURL(manifestURL)
111 .setStatus(static_cast<int>(host->status())); 112 .setStatus(static_cast<int>(host->status()));
112 result->addItem(value); 113 result->addItem(value);
113 } 114 }
114 } 115 }
115 } 116 }
116 117
117 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(Er rorString* errorString, String frameId) 118 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(Er rorString* errorString, String frameId)
118 { 119 {
119 LocalFrame* frame = InspectorResolver::resolveFrame(m_inspectedFrame, frameI d); 120 LocalFrame* frame = m_pageAgent->assertFrame(errorString, frameId);
120 if (!frame) { 121 if (!frame)
121 *errorString = "No frame for given id found";
122 return nullptr; 122 return nullptr;
123 } 123
124 DocumentLoader* documentLoader = frame->loader().documentLoader(); 124 return InspectorPageAgent::assertDocumentLoader(errorString, frame);
125 if (!documentLoader) {
126 *errorString = "No documentLoader for given frame found";
127 return nullptr;
128 }
129 return documentLoader;
130 } 125 }
131 126
132 void InspectorApplicationCacheAgent::getManifestForFrame(ErrorString* errorStrin g, const String& frameId, String* manifestURL) 127 void InspectorApplicationCacheAgent::getManifestForFrame(ErrorString* errorStrin g, const String& frameId, String* manifestURL)
133 { 128 {
134 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId); 129 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId);
135 if (!documentLoader) 130 if (!documentLoader)
136 return; 131 return;
137 132
138 ApplicationCacheHost::CacheInfo info = documentLoader->applicationCacheHost( )->applicationCacheInfo(); 133 ApplicationCacheHost::CacheInfo info = documentLoader->applicationCacheHost( )->applicationCacheInfo();
139 *manifestURL = info.m_manifest.string(); 134 *manifestURL = info.m_manifest.string();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 192
198 RefPtr<TypeBuilder::ApplicationCache::ApplicationCacheResource> value = Type Builder::ApplicationCache::ApplicationCacheResource::create() 193 RefPtr<TypeBuilder::ApplicationCache::ApplicationCacheResource> value = Type Builder::ApplicationCache::ApplicationCacheResource::create()
199 .setUrl(resourceInfo.m_resource.string()) 194 .setUrl(resourceInfo.m_resource.string())
200 .setSize(static_cast<int>(resourceInfo.m_size)) 195 .setSize(static_cast<int>(resourceInfo.m_size))
201 .setType(builder.toString()); 196 .setType(builder.toString());
202 return value; 197 return value;
203 } 198 }
204 199
205 DEFINE_TRACE(InspectorApplicationCacheAgent) 200 DEFINE_TRACE(InspectorApplicationCacheAgent)
206 { 201 {
207 visitor->trace(m_inspectedFrame); 202 visitor->trace(m_pageAgent);
208 InspectorBaseAgent::trace(visitor); 203 InspectorBaseAgent::trace(visitor);
209 } 204 }
210 205
211 } // namespace blink 206 } // namespace blink
212 207
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorApplicationCacheAgent.h ('k') | Source/core/inspector/InspectorCSSAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698