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

Unified Diff: Source/core/inspector/InspectorPageAgent.cpp

Issue 1085033003: Introduce InspectorIdentifiers<> and use it to assign/lookup LocalFrame and DocumentLoader (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: win build error fixed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.h ('k') | Source/core/inspector/InspectorResourceAgent.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorPageAgent.cpp
diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp
index 88b69787fadf98c485074e96fdae38581c9e74cc..5a27c827c06b660ccfa1764f7f6295dc35b0fd2e 100644
--- a/Source/core/inspector/InspectorPageAgent.cpp
+++ b/Source/core/inspector/InspectorPageAgent.cpp
@@ -51,9 +51,9 @@
#include "core/html/parser/TextResourceDecoder.h"
#include "core/inspector/ContentSearchUtils.h"
#include "core/inspector/DOMPatchSupport.h"
-#include "core/inspector/IdentifiersFactory.h"
#include "core/inspector/InspectorCSSAgent.h"
#include "core/inspector/InspectorDebuggerAgent.h"
+#include "core/inspector/InspectorIdentifiers.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/InspectorOverlay.h"
#include "core/inspector/InspectorResourceContentLoader.h"
@@ -91,6 +91,11 @@ KURL urlWithoutFragment(const KURL& url)
return result;
}
+String frameId(LocalFrame* frame)
+{
+ return frame ? InspectorIdentifiers<LocalFrame>::identifier(frame) : "";
+}
+
}
class InspectorPageAgent::GetResourceContentLoadListener final : public VoidCallback {
@@ -670,12 +675,7 @@ void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame)
void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame)
{
- HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(frame);
- if (iterator != m_frameToIdentifier.end()) {
- frontend()->frameDetached(iterator->value);
- m_identifierToFrame.remove(iterator->value);
- m_frameToIdentifier.remove(iterator);
- }
+ frontend()->frameDetached(frameId(frame));
}
FrameHost* InspectorPageAgent::frameHost()
@@ -685,37 +685,8 @@ FrameHost* InspectorPageAgent::frameHost()
LocalFrame* InspectorPageAgent::frameForId(const String& frameId)
{
- return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId);
-}
-
-String InspectorPageAgent::frameId(LocalFrame* frame)
-{
- if (!frame)
- return "";
- String identifier = m_frameToIdentifier.get(frame);
- if (identifier.isNull()) {
- identifier = IdentifiersFactory::createIdentifier();
- m_frameToIdentifier.set(frame, identifier);
- m_identifierToFrame.set(identifier, frame);
- }
- return identifier;
-}
-
-bool InspectorPageAgent::hasIdForFrame(LocalFrame* frame) const
-{
- return frame && m_frameToIdentifier.contains(frame);
-}
-
-String InspectorPageAgent::loaderId(DocumentLoader* loader)
-{
- if (!loader)
- return "";
- String identifier = m_loaderToIdentifier.get(loader);
- if (identifier.isNull()) {
- identifier = IdentifiersFactory::createIdentifier();
- m_loaderToIdentifier.set(loader, identifier);
- }
- return identifier;
+ LocalFrame* frame = InspectorIdentifiers<LocalFrame>::lookup(frameId);
+ return frame && frame->instrumentingAgents() == m_inspectedFrame->instrumentingAgents() ? frame : nullptr;
}
LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& originRawString)
@@ -752,13 +723,6 @@ DocumentLoader* InspectorPageAgent::assertDocumentLoader(ErrorString* errorStrin
return documentLoader;
}
-void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader* loader)
-{
- HashMap<DocumentLoader*, String>::iterator iterator = m_loaderToIdentifier.find(loader);
- if (iterator != m_loaderToIdentifier.end())
- m_loaderToIdentifier.remove(iterator);
-}
-
void InspectorPageAgent::frameStartedLoading(LocalFrame* frame)
{
frontend()->frameStartedLoading(frameId(frame));
@@ -823,7 +787,7 @@ PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Loc
{
RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::create()
.setId(frameId(frame))
- .setLoaderId(loaderId(frame->loader().documentLoader()))
+ .setLoaderId(InspectorIdentifiers<DocumentLoader>::identifier(frame->loader().documentLoader()))
.setUrl(urlWithoutFragment(frame->document()->url()).string())
.setMimeType(frame->loader().documentLoader()->responseMIMEType())
.setSecurityOrigin(frame->document()->securityOrigin()->toRawString());
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.h ('k') | Source/core/inspector/InspectorResourceAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698