| OLD | NEW |
| 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 Loading... |
| 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" | 31 #include "core/inspector/InspectorResolver.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(InspectorPageAgen
t* pageAgent) | 45 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(LocalFrame* inspe
ctedFrame) |
| 46 : InspectorBaseAgent<InspectorApplicationCacheAgent, InspectorFrontend::Appl
icationCache>("ApplicationCache") | 46 : InspectorBaseAgent<InspectorApplicationCacheAgent, InspectorFrontend::Appl
icationCache>("ApplicationCache") |
| 47 , m_pageAgent(pageAgent) | 47 , m_inspectedFrame(inspectedFrame) |
| 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 Loading... |
| 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_pageAgent->inspectedFrame()) | 89 if (frame == m_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 LocalFrame* inspectedFrame = m_pageAgent->inspectedFrame(); | 97 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()) | 98 if (!frame->isLocalFrame()) |
| 100 continue; | 99 continue; |
| 101 DocumentLoader* documentLoader = toLocalFrame(frame)->loader().documentL
oader(); | 100 DocumentLoader* documentLoader = toLocalFrame(frame)->loader().documentL
oader(); |
| 102 if (!documentLoader) | 101 if (!documentLoader) |
| 103 continue; | 102 continue; |
| 104 | 103 |
| 105 ApplicationCacheHost* host = documentLoader->applicationCacheHost(); | 104 ApplicationCacheHost* host = documentLoader->applicationCacheHost(); |
| 106 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); | 105 ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo(); |
| 107 String manifestURL = info.m_manifest.string(); | 106 String manifestURL = info.m_manifest.string(); |
| 108 if (!manifestURL.isEmpty()) { | 107 if (!manifestURL.isEmpty()) { |
| 109 RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = Typ
eBuilder::ApplicationCache::FrameWithManifest::create() | 108 RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = Typ
eBuilder::ApplicationCache::FrameWithManifest::create() |
| 110 .setFrameId(InspectorIdentifiers<LocalFrame>::identifier(toLocal
Frame(frame))) | 109 .setFrameId(InspectorIdentifiers<LocalFrame>::identifier(toLocal
Frame(frame))) |
| 111 .setManifestURL(manifestURL) | 110 .setManifestURL(manifestURL) |
| 112 .setStatus(static_cast<int>(host->status())); | 111 .setStatus(static_cast<int>(host->status())); |
| 113 result->addItem(value); | 112 result->addItem(value); |
| 114 } | 113 } |
| 115 } | 114 } |
| 116 } | 115 } |
| 117 | 116 |
| 118 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(Er
rorString* errorString, String frameId) | 117 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(Er
rorString* errorString, String frameId) |
| 119 { | 118 { |
| 120 LocalFrame* frame = m_pageAgent->assertFrame(errorString, frameId); | 119 LocalFrame* frame = InspectorResolver::resolveFrame(m_inspectedFrame, frameI
d); |
| 121 if (!frame) | 120 if (!frame) { |
| 121 *errorString = "No frame for given id found"; |
| 122 return nullptr; | 122 return nullptr; |
| 123 | 123 } |
| 124 return InspectorPageAgent::assertDocumentLoader(errorString, frame); | 124 DocumentLoader* documentLoader = frame->loader().documentLoader(); |
| 125 if (!documentLoader) { |
| 126 *errorString = "No documentLoader for given frame found"; |
| 127 return nullptr; |
| 128 } |
| 129 return documentLoader; |
| 125 } | 130 } |
| 126 | 131 |
| 127 void InspectorApplicationCacheAgent::getManifestForFrame(ErrorString* errorStrin
g, const String& frameId, String* manifestURL) | 132 void InspectorApplicationCacheAgent::getManifestForFrame(ErrorString* errorStrin
g, const String& frameId, String* manifestURL) |
| 128 { | 133 { |
| 129 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString,
frameId); | 134 DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString,
frameId); |
| 130 if (!documentLoader) | 135 if (!documentLoader) |
| 131 return; | 136 return; |
| 132 | 137 |
| 133 ApplicationCacheHost::CacheInfo info = documentLoader->applicationCacheHost(
)->applicationCacheInfo(); | 138 ApplicationCacheHost::CacheInfo info = documentLoader->applicationCacheHost(
)->applicationCacheInfo(); |
| 134 *manifestURL = info.m_manifest.string(); | 139 *manifestURL = info.m_manifest.string(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 197 |
| 193 RefPtr<TypeBuilder::ApplicationCache::ApplicationCacheResource> value = Type
Builder::ApplicationCache::ApplicationCacheResource::create() | 198 RefPtr<TypeBuilder::ApplicationCache::ApplicationCacheResource> value = Type
Builder::ApplicationCache::ApplicationCacheResource::create() |
| 194 .setUrl(resourceInfo.m_resource.string()) | 199 .setUrl(resourceInfo.m_resource.string()) |
| 195 .setSize(static_cast<int>(resourceInfo.m_size)) | 200 .setSize(static_cast<int>(resourceInfo.m_size)) |
| 196 .setType(builder.toString()); | 201 .setType(builder.toString()); |
| 197 return value; | 202 return value; |
| 198 } | 203 } |
| 199 | 204 |
| 200 DEFINE_TRACE(InspectorApplicationCacheAgent) | 205 DEFINE_TRACE(InspectorApplicationCacheAgent) |
| 201 { | 206 { |
| 202 visitor->trace(m_pageAgent); | 207 visitor->trace(m_inspectedFrame); |
| 203 InspectorBaseAgent::trace(visitor); | 208 InspectorBaseAgent::trace(visitor); |
| 204 } | 209 } |
| 205 | 210 |
| 206 } // namespace blink | 211 } // namespace blink |
| 207 | 212 |
| OLD | NEW |