Commit 4731f799 authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

Port InspectorApplicationCacheAgent to InspectorAgentState.

Bug: 851762
Change-Id: I0208bb9a528c0e40cdb2b962461ac90225cb31b1
Reviewed-on: https://chromium-review.googlesource.com/1164062
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581073}
parent 800f506a
...@@ -35,36 +35,32 @@ ...@@ -35,36 +35,32 @@
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink { namespace blink {
using protocol::Response; using protocol::Response;
namespace ApplicationCacheAgentState {
static const char kApplicationCacheAgentEnabled[] =
"applicationCacheAgentEnabled";
}
InspectorApplicationCacheAgent::InspectorApplicationCacheAgent( InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(
InspectedFrames* inspected_frames) InspectedFrames* inspected_frames)
: inspected_frames_(inspected_frames) {} : inspected_frames_(inspected_frames),
enabled_(&agent_state_, /*default_value=*/false) {}
void InspectorApplicationCacheAgent::InnerEnable() {
enabled_.Set(true);
instrumenting_agents_->addInspectorApplicationCacheAgent(this);
GetFrontend()->networkStateUpdated(GetNetworkStateNotifier().OnLine());
}
void InspectorApplicationCacheAgent::Restore() { void InspectorApplicationCacheAgent::Restore() {
if (state_->booleanProperty( if (enabled_.Get())
ApplicationCacheAgentState::kApplicationCacheAgentEnabled, false)) { InnerEnable();
enable();
}
} }
Response InspectorApplicationCacheAgent::enable() { Response InspectorApplicationCacheAgent::enable() {
state_->setBoolean(ApplicationCacheAgentState::kApplicationCacheAgentEnabled, if (!enabled_.Get())
true); InnerEnable();
instrumenting_agents_->addInspectorApplicationCacheAgent(this);
GetFrontend()->networkStateUpdated(GetNetworkStateNotifier().OnLine());
return Response::OK(); return Response::OK();
} }
Response InspectorApplicationCacheAgent::disable() { Response InspectorApplicationCacheAgent::disable() {
state_->setBoolean(ApplicationCacheAgentState::kApplicationCacheAgentEnabled, enabled_.Clear();
false);
instrumenting_agents_->removeInspectorApplicationCacheAgent(this); instrumenting_agents_->removeInspectorApplicationCacheAgent(this);
return Response::OK(); return Response::OK();
} }
......
...@@ -68,6 +68,9 @@ class CORE_EXPORT InspectorApplicationCacheAgent final ...@@ -68,6 +68,9 @@ class CORE_EXPORT InspectorApplicationCacheAgent final
std::unique_ptr<protocol::ApplicationCache::ApplicationCache>*) override; std::unique_ptr<protocol::ApplicationCache::ApplicationCache>*) override;
private: private:
// Unconditionally enables the agent, even if |enabled_.Get()==true|.
// For idempotence, call enable().
void InnerEnable();
explicit InspectorApplicationCacheAgent(InspectedFrames*); explicit InspectorApplicationCacheAgent(InspectedFrames*);
std::unique_ptr<protocol::ApplicationCache::ApplicationCache> std::unique_ptr<protocol::ApplicationCache::ApplicationCache>
...@@ -85,6 +88,7 @@ class CORE_EXPORT InspectorApplicationCacheAgent final ...@@ -85,6 +88,7 @@ class CORE_EXPORT InspectorApplicationCacheAgent final
DocumentLoader*&); DocumentLoader*&);
Member<InspectedFrames> inspected_frames_; Member<InspectedFrames> inspected_frames_;
InspectorAgentState::Boolean enabled_;
DISALLOW_COPY_AND_ASSIGN(InspectorApplicationCacheAgent); DISALLOW_COPY_AND_ASSIGN(InspectorApplicationCacheAgent);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment