[DevTools] Console Message Storage moved from top local frame to frame host

Console Message Storage was moved to frame host because remote frame which used in site-per-process mode not contains Frame Console.
Instrumentation Code generator supports agent dispatching by different objects e.g. messagesCleared dispatch by execution context for workers and by FrameHost for pages.

R=vsevik@chromium.org
BUG=421948

Review URL: https://codereview.chromium.org/645693003

git-svn-id: svn://svn.chromium.org/blink/trunk@183735 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5380b417
...@@ -165,16 +165,8 @@ void FrameConsole::unmute() ...@@ -165,16 +165,8 @@ void FrameConsole::unmute()
ConsoleMessageStorage* FrameConsole::messageStorage() ConsoleMessageStorage* FrameConsole::messageStorage()
{ {
LocalFrame* curFrame = m_frame; ASSERT(m_frame->page());
// FIXME: Move the console's messageStorage off the main frame. return &m_frame->page()->frameHost().consoleMessageStorage();
Frame* topFrame = curFrame->localFrameRoot();
ASSERT(topFrame->isLocalFrame());
LocalFrame* localTopFrame = toLocalFrame(topFrame);
if (localTopFrame != curFrame)
return localTopFrame->console().messageStorage();
if (!m_consoleMessageStorage)
m_consoleMessageStorage = ConsoleMessageStorage::createForFrame(m_frame);
return m_consoleMessageStorage.get();
} }
void FrameConsole::clearMessages() void FrameConsole::clearMessages()
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "core/frame/FrameHost.h" #include "core/frame/FrameHost.h"
#include "core/frame/EventHandlerRegistry.h" #include "core/frame/EventHandlerRegistry.h"
#include "core/inspector/ConsoleMessageStorage.h"
#include "core/page/Chrome.h" #include "core/page/Chrome.h"
#include "core/page/ChromeClient.h" #include "core/page/ChromeClient.h"
#include "core/page/Page.h" #include "core/page/Page.h"
...@@ -47,6 +48,7 @@ FrameHost::FrameHost(Page& page) ...@@ -47,6 +48,7 @@ FrameHost::FrameHost(Page& page)
: m_page(&page) : m_page(&page)
, m_pinchViewport(PinchViewport::create(*this)) , m_pinchViewport(PinchViewport::create(*this))
, m_eventHandlerRegistry(adoptPtrWillBeNoop(new EventHandlerRegistry(*this))) , m_eventHandlerRegistry(adoptPtrWillBeNoop(new EventHandlerRegistry(*this)))
, m_consoleMessageStorage(ConsoleMessageStorage::createForFrameHost(this))
{ {
} }
...@@ -85,11 +87,17 @@ EventHandlerRegistry& FrameHost::eventHandlerRegistry() const ...@@ -85,11 +87,17 @@ EventHandlerRegistry& FrameHost::eventHandlerRegistry() const
return *m_eventHandlerRegistry; return *m_eventHandlerRegistry;
} }
ConsoleMessageStorage& FrameHost::consoleMessageStorage() const
{
return *m_consoleMessageStorage;
}
void FrameHost::trace(Visitor* visitor) void FrameHost::trace(Visitor* visitor)
{ {
visitor->trace(m_page); visitor->trace(m_page);
visitor->trace(m_pinchViewport); visitor->trace(m_pinchViewport);
visitor->trace(m_eventHandlerRegistry); visitor->trace(m_eventHandlerRegistry);
visitor->trace(m_consoleMessageStorage);
} }
} }
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
namespace blink { namespace blink {
class Chrome; class Chrome;
class ConsoleMessageStorage;
class EventHandlerRegistry; class EventHandlerRegistry;
class Page; class Page;
class PinchViewport; class PinchViewport;
...@@ -80,6 +81,8 @@ public: ...@@ -80,6 +81,8 @@ public:
const AtomicString& overrideEncoding() const { return m_overrideEncoding; } const AtomicString& overrideEncoding() const { return m_overrideEncoding; }
void setOverrideEncoding(const AtomicString& encoding) { m_overrideEncoding = encoding; } void setOverrideEncoding(const AtomicString& encoding) { m_overrideEncoding = encoding; }
ConsoleMessageStorage& consoleMessageStorage() const;
void trace(Visitor*); void trace(Visitor*);
private: private:
...@@ -88,6 +91,7 @@ private: ...@@ -88,6 +91,7 @@ private:
RawPtrWillBeMember<Page> m_page; RawPtrWillBeMember<Page> m_page;
const OwnPtrWillBeMember<PinchViewport> m_pinchViewport; const OwnPtrWillBeMember<PinchViewport> m_pinchViewport;
const OwnPtrWillBeMember<EventHandlerRegistry> m_eventHandlerRegistry; const OwnPtrWillBeMember<EventHandlerRegistry> m_eventHandlerRegistry;
const OwnPtrWillBeMember<ConsoleMessageStorage> m_consoleMessageStorage;
AtomicString m_overrideEncoding; AtomicString m_overrideEncoding;
}; };
......
...@@ -545,7 +545,7 @@ Page* LocalDOMWindow::page() ...@@ -545,7 +545,7 @@ Page* LocalDOMWindow::page()
void LocalDOMWindow::willDetachFrameHost() void LocalDOMWindow::willDetachFrameHost()
{ {
m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this); m_frame->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this);
m_frame->console().messageStorage()->frameWindowDiscarded(this); m_frame->host()->consoleMessageStorage().frameWindowDiscarded(this);
InspectorInstrumentation::frameWindowDiscarded(m_frame, this); InspectorInstrumentation::frameWindowDiscarded(m_frame, this);
} }
......
...@@ -308,8 +308,8 @@ void LocalFrame::setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow> domWindow) ...@@ -308,8 +308,8 @@ void LocalFrame::setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow> domWindow)
// die with the window. And the registered DOMWindowProperty instances that don't, // die with the window. And the registered DOMWindowProperty instances that don't,
// only keep a weak reference to this frame, so there's no need to be // only keep a weak reference to this frame, so there's no need to be
// explicitly notified that this frame is going away. // explicitly notified that this frame is going away.
if (m_domWindow) { if (m_domWindow && host()) {
console().messageStorage()->frameWindowDiscarded(m_domWindow.get()); host()->consoleMessageStorage().frameWindowDiscarded(m_domWindow.get());
InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get()); InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get());
} }
if (domWindow) if (domWindow)
......
...@@ -336,12 +336,14 @@ class Method: ...@@ -336,12 +336,14 @@ class Method:
elif self.returns_value: elif self.returns_value:
body_lines.append("\n return %s;" % self.default_return_value) body_lines.append("\n return %s;" % self.default_return_value)
cpp_lines.append(template_outofline.substitute( generated_outofline = template_outofline.substitute(
None, None,
return_type=self.return_type, return_type=self.return_type,
name=self.name, name=self.name,
params_impl=", ".join(map(Parameter.to_str_class_and_name, self.params_impl)), params_impl=", ".join(map(Parameter.to_str_class_and_name, self.params_impl)),
impl_lines="".join(body_lines))) impl_lines="".join(body_lines))
if generated_outofline not in cpp_lines:
cpp_lines.append(generated_outofline)
def generate_agent_call(self, agent): def generate_agent_call(self, agent):
agent_class, agent_getter = agent_getter_signature(agent) agent_class, agent_getter = agent_getter_signature(agent)
......
...@@ -16,14 +16,14 @@ static const unsigned maxConsoleMessageCount = 1000; ...@@ -16,14 +16,14 @@ static const unsigned maxConsoleMessageCount = 1000;
ConsoleMessageStorage::ConsoleMessageStorage(ExecutionContext* context) ConsoleMessageStorage::ConsoleMessageStorage(ExecutionContext* context)
: m_expiredCount(0) : m_expiredCount(0)
, m_context(context) , m_context(context)
, m_frame(nullptr) , m_frameHost(nullptr)
{ {
} }
ConsoleMessageStorage::ConsoleMessageStorage(LocalFrame* frame) ConsoleMessageStorage::ConsoleMessageStorage(FrameHost* frameHost)
: m_expiredCount(0) : m_expiredCount(0)
, m_context(nullptr) , m_context(nullptr)
, m_frame(frame) , m_frameHost(frameHost)
{ {
} }
...@@ -35,7 +35,10 @@ void ConsoleMessageStorage::reportMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> ...@@ -35,7 +35,10 @@ void ConsoleMessageStorage::reportMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>
if (message->type() == ClearMessageType) if (message->type() == ClearMessageType)
clear(); clear();
InspectorInstrumentation::addMessageToConsole(executionContext(), message.get()); if (m_frameHost)
InspectorInstrumentation::addMessageToConsole(m_frameHost, message.get());
else
InspectorInstrumentation::addMessageToConsole(m_context, message.get());
ASSERT(m_messages.size() <= maxConsoleMessageCount); ASSERT(m_messages.size() <= maxConsoleMessageCount);
if (m_messages.size() == maxConsoleMessageCount) { if (m_messages.size() == maxConsoleMessageCount) {
...@@ -47,7 +50,10 @@ void ConsoleMessageStorage::reportMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> ...@@ -47,7 +50,10 @@ void ConsoleMessageStorage::reportMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>
void ConsoleMessageStorage::clear() void ConsoleMessageStorage::clear()
{ {
InspectorInstrumentation::consoleMessagesCleared(executionContext()); if (m_frameHost)
InspectorInstrumentation::consoleMessagesCleared(m_frameHost);
else
InspectorInstrumentation::consoleMessagesCleared(m_context);
m_messages.clear(); m_messages.clear();
m_expiredCount = 0; m_expiredCount = 0;
} }
...@@ -89,16 +95,11 @@ int ConsoleMessageStorage::expiredCount() const ...@@ -89,16 +95,11 @@ int ConsoleMessageStorage::expiredCount() const
return m_expiredCount; return m_expiredCount;
} }
ExecutionContext* ConsoleMessageStorage::executionContext() const
{
return m_frame ? m_frame->document() : m_context;
}
void ConsoleMessageStorage::trace(Visitor* visitor) void ConsoleMessageStorage::trace(Visitor* visitor)
{ {
visitor->trace(m_messages); visitor->trace(m_messages);
visitor->trace(m_context); visitor->trace(m_context);
visitor->trace(m_frame); visitor->trace(m_frameHost);
} }
} // namespace blink } // namespace blink
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace blink { namespace blink {
class FrameHost;
class LocalDOMWindow; class LocalDOMWindow;
class WorkerGlobalScopeProxy; class WorkerGlobalScopeProxy;
...@@ -23,9 +24,9 @@ public: ...@@ -23,9 +24,9 @@ public:
return adoptPtrWillBeNoop(new ConsoleMessageStorage(context)); return adoptPtrWillBeNoop(new ConsoleMessageStorage(context));
} }
static PassOwnPtrWillBeRawPtr<ConsoleMessageStorage> createForFrame(LocalFrame* frame) static PassOwnPtrWillBeRawPtr<ConsoleMessageStorage> createForFrameHost(FrameHost* frameHost)
{ {
return adoptPtrWillBeNoop(new ConsoleMessageStorage(frame)); return adoptPtrWillBeNoop(new ConsoleMessageStorage(frameHost));
} }
void reportMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>); void reportMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>);
...@@ -45,14 +46,12 @@ public: ...@@ -45,14 +46,12 @@ public:
private: private:
explicit ConsoleMessageStorage(ExecutionContext*); explicit ConsoleMessageStorage(ExecutionContext*);
explicit ConsoleMessageStorage(LocalFrame*); explicit ConsoleMessageStorage(FrameHost*);
ExecutionContext* executionContext() const;
int m_expiredCount; int m_expiredCount;
WillBeHeapDeque<RefPtrWillBeMember<ConsoleMessage> > m_messages; WillBeHeapDeque<RefPtrWillBeMember<ConsoleMessage> > m_messages;
RawPtrWillBeMember<ExecutionContext> m_context; RawPtrWillBeMember<ExecutionContext> m_context;
RawPtrWillBeMember<LocalFrame> m_frame; RawPtrWillBeMember<FrameHost> m_frameHost;
}; };
} // namespace blink } // namespace blink
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "core/events/EventTarget.h" #include "core/events/EventTarget.h"
#include "core/fetch/FetchInitiatorInfo.h" #include "core/fetch/FetchInitiatorInfo.h"
#include "core/frame/FrameHost.h"
#include "core/inspector/InspectorCSSAgent.h" #include "core/inspector/InspectorCSSAgent.h"
#include "core/inspector/InspectorConsoleAgent.h" #include "core/inspector/InspectorConsoleAgent.h"
#include "core/inspector/InspectorController.h" #include "core/inspector/InspectorController.h"
...@@ -228,6 +229,11 @@ InstrumentingAgents* instrumentingAgentsFor(WorkerGlobalScope* workerGlobalScope ...@@ -228,6 +229,11 @@ InstrumentingAgents* instrumentingAgentsFor(WorkerGlobalScope* workerGlobalScope
return instrumentationForWorkerGlobalScope(workerGlobalScope); return instrumentationForWorkerGlobalScope(workerGlobalScope);
} }
InstrumentingAgents* instrumentingAgentsFor(FrameHost* host)
{
return instrumentationForPage(&host->page());
}
InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ExecutionContext* context) InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ExecutionContext* context)
{ {
if (context->isWorkerGlobalScope()) if (context->isWorkerGlobalScope())
......
...@@ -54,6 +54,7 @@ namespace blink { ...@@ -54,6 +54,7 @@ namespace blink {
class Document; class Document;
class EventTarget; class EventTarget;
class ExecutionContext; class ExecutionContext;
class FrameHost;
class InspectorTimelineAgent; class InspectorTimelineAgent;
class InstrumentingAgents; class InstrumentingAgents;
class ThreadableLoaderClient; class ThreadableLoaderClient;
...@@ -108,6 +109,7 @@ InstrumentingAgents* instrumentingAgentsFor(Document*); ...@@ -108,6 +109,7 @@ InstrumentingAgents* instrumentingAgentsFor(Document*);
InstrumentingAgents* instrumentingAgentsFor(RenderObject*); InstrumentingAgents* instrumentingAgentsFor(RenderObject*);
InstrumentingAgents* instrumentingAgentsFor(Node*); InstrumentingAgents* instrumentingAgentsFor(Node*);
InstrumentingAgents* instrumentingAgentsFor(WorkerGlobalScope*); InstrumentingAgents* instrumentingAgentsFor(WorkerGlobalScope*);
InstrumentingAgents* instrumentingAgentsFor(FrameHost*);
// Helper for the one above. // Helper for the one above.
InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ExecutionContext*); InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ExecutionContext*);
......
...@@ -480,6 +480,9 @@ interface InspectorConsoleInstrumentation { ...@@ -480,6 +480,9 @@ interface InspectorConsoleInstrumentation {
class ConsoleMessage; class ConsoleMessage;
[Console, Debugger]
void addMessageToConsole(FrameHost* frameHost, ConsoleMessage* consoleMessage);
[Console, Debugger] [Console, Debugger]
void addMessageToConsole(ExecutionContext* context, ConsoleMessage* consoleMessage); void addMessageToConsole(ExecutionContext* context, ConsoleMessage* consoleMessage);
...@@ -504,6 +507,9 @@ class ConsoleMessage; ...@@ -504,6 +507,9 @@ class ConsoleMessage;
[Profiler, Inline=FastReturn] [Profiler, Inline=FastReturn]
void consoleProfileEnd(ExecutionContext* context, const String& title); void consoleProfileEnd(ExecutionContext* context, const String& title);
[Console]
void consoleMessagesCleared(FrameHost* frameHost);
[Console] [Console]
void consoleMessagesCleared(ExecutionContext* context); void consoleMessagesCleared(ExecutionContext* context);
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "core/dom/NodeTraversal.h" #include "core/dom/NodeTraversal.h"
#include "core/dom/shadow/ShadowRoot.h" #include "core/dom/shadow/ShadowRoot.h"
#include "core/frame/FrameConsole.h" #include "core/frame/FrameConsole.h"
#include "core/frame/FrameHost.h"
#include "core/inspector/InjectedScriptHost.h" #include "core/inspector/InjectedScriptHost.h"
#include "core/inspector/InjectedScriptManager.h" #include "core/inspector/InjectedScriptManager.h"
#include "core/inspector/InspectorDOMAgent.h" #include "core/inspector/InspectorDOMAgent.h"
...@@ -71,7 +72,7 @@ void PageConsoleAgent::clearMessages(ErrorString* errorString) ...@@ -71,7 +72,7 @@ void PageConsoleAgent::clearMessages(ErrorString* errorString)
ConsoleMessageStorage* PageConsoleAgent::messageStorage() ConsoleMessageStorage* PageConsoleAgent::messageStorage()
{ {
return m_page->deprecatedLocalMainFrame()->console().messageStorage(); return &m_page->frameHost().consoleMessageStorage();
} }
class InspectableNode final : public InjectedScriptHost::InspectableObject { class InspectableNode final : public InjectedScriptHost::InspectableObject {
......
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