From bc10cd41679745a100dc810c93c8fe8cdd0cdb7a Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Thu, 20 Nov 2014 11:30:01 -0800 Subject: [PATCH] Move inspector_backend_mojo.cc to v8_inspector Also fixed several chromium style errors in the file. I had to make web depend on v8_inspector for the time being until v8_inspector can be weened off of the Page class. R=abarth@chromium.org, yurys@chromium.org BUG=435243 Review URL: https://codereview.chromium.org/749523002 --- engine/BUILD.gn | 1 - engine/core/BUILD.gn | 1 - engine/core/core.gni | 2 - engine/v8_inspector/BUILD.gn | 12 +++- .../inspector_backend_mojo.cc | 55 ++++++++++--------- .../inspector_backend_mojo.h | 6 +- engine/web/BUILD.gn | 3 + engine/web/WebViewImpl.cpp | 2 +- engine/web/WebViewImpl.h | 4 +- 9 files changed, 47 insertions(+), 39 deletions(-) rename engine/{core/inspector => v8_inspector}/inspector_backend_mojo.cc (73%) rename engine/{core/inspector => v8_inspector}/inspector_backend_mojo.h (95%) diff --git a/engine/BUILD.gn b/engine/BUILD.gn index fcdbb67b534..4a385f1c5d4 100644 --- a/engine/BUILD.gn +++ b/engine/BUILD.gn @@ -79,6 +79,5 @@ group("engine") { "//sky/engine/public:sky_headers", "//sky/engine/web", "//sky/engine/platform", - "//sky/engine/v8_inspector", ] } diff --git a/engine/core/BUILD.gn b/engine/core/BUILD.gn index c10809f461b..d7f77ff61c5 100644 --- a/engine/core/BUILD.gn +++ b/engine/core/BUILD.gn @@ -26,7 +26,6 @@ source_set("libraries") { "//mojo/services/public/interfaces/navigation", "//skia", "//sky/engine/wtf", - "//sky/services/inspector:bindings", "//third_party/angle:translator", "//third_party/iccjpeg", "//third_party/libpng", diff --git a/engine/core/core.gni b/engine/core/core.gni index 2545029c51d..87daf505b0a 100644 --- a/engine/core/core.gni +++ b/engine/core/core.gni @@ -1052,8 +1052,6 @@ sky_core_files = [ "inspector/InjectedScriptHost.h", "inspector/InjectedScriptManager.cpp", "inspector/InjectedScriptManager.h", - "inspector/inspector_backend_mojo.cc", - "inspector/inspector_backend_mojo.h", "inspector/InspectorBaseAgent.cpp", "inspector/InspectorBaseAgent.h", "inspector/InspectorCounters.cpp", diff --git a/engine/v8_inspector/BUILD.gn b/engine/v8_inspector/BUILD.gn index 70e09a3bef3..b8c2019e518 100644 --- a/engine/v8_inspector/BUILD.gn +++ b/engine/v8_inspector/BUILD.gn @@ -11,8 +11,13 @@ component("v8_inspector") { output_name = "v8_inspector" deps = [ - "//sky/engine/core", - "//sky/engine/platform", + "//base", + "//mojo/public/cpp/application", + "//mojo/public/interfaces/application", + "//sky/engine/core", # FIXME: Remove. + "//sky/engine/platform", # FIXME: Remove. + "//sky/engine/public:sky_headers", + "//sky/services/inspector:bindings", ] configs += [ @@ -22,6 +27,7 @@ component("v8_inspector") { ] sources = [ - + "inspector_backend_mojo.cc", + "inspector_backend_mojo.h", ] } diff --git a/engine/core/inspector/inspector_backend_mojo.cc b/engine/v8_inspector/inspector_backend_mojo.cc similarity index 73% rename from engine/core/inspector/inspector_backend_mojo.cc rename to engine/v8_inspector/inspector_backend_mojo.cc index ca030fcb3c2..01a69f0a413 100644 --- a/engine/core/inspector/inspector_backend_mojo.cc +++ b/engine/v8_inspector/inspector_backend_mojo.cc @@ -2,45 +2,43 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "config.h" -#include "core/inspector/inspector_backend_mojo.h" +#include "sky/engine/config.h" +#include "v8_inspector/inspector_backend_mojo.h" #include "base/memory/scoped_ptr.h" #include "base/run_loop.h" #include "bindings/core/v8/PageScriptDebugServer.h" #include "bindings/core/v8/ScriptController.h" -#include "core/frame/FrameHost.h" -#include "core/inspector/InspectorState.h" -#include "core/inspector/InstrumentingAgents.h" -#include "core/inspector/PageDebuggerAgent.h" -#include "core/page/Page.h" #include "gen/sky/core/InspectorBackendDispatcher.h" #include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/application/service_provider_impl.h" #include "mojo/public/interfaces/application/shell.mojom.h" -#include "platform/JSONValues.h" -#include "public/platform/ServiceProvider.h" +#include "sky/engine/core/frame/FrameHost.h" +#include "sky/engine/core/inspector/InspectorState.h" +#include "sky/engine/core/inspector/InstrumentingAgents.h" +#include "sky/engine/core/inspector/PageDebuggerAgent.h" +#include "sky/engine/core/page/Page.h" +#include "sky/engine/platform/JSONValues.h" +#include "sky/engine/public/platform/ServiceProvider.h" namespace blink { class MessageLoopAdaptor : public PageScriptDebugServer::ClientMessageLoop { -public: - MessageLoopAdaptor() { } + public: + MessageLoopAdaptor() {} -private: - virtual void run(Page* page) - { - run_loop_.reset(new base::RunLoop()); - run_loop_->Run(); - } + private: + virtual void run(Page* page) { + run_loop_.reset(new base::RunLoop()); + run_loop_->Run(); + } - virtual void quitNow() - { - if (run_loop_) - run_loop_->Quit(); - } + virtual void quitNow() { + if (run_loop_) + run_loop_->Quit(); + } - scoped_ptr run_loop_; + scoped_ptr run_loop_; }; InspectorBackendMojo::InspectorBackendMojo(const FrameHost& frame_host) @@ -59,7 +57,8 @@ void InspectorBackendMojo::Connect() { frontend_.set_client(this); // Theoretically we should load our state from the inspector cookie. - inspector_state_ = adoptPtr(new InspectorState(nullptr, JSONObject::create())); + inspector_state_ = + adoptPtr(new InspectorState(nullptr, JSONObject::create())); old_frontend_ = adoptPtr(new InspectorFrontend(this)); v8::Isolate* isolate = frame_host_.page().mainFrame()->script().isolate(); @@ -69,7 +68,9 @@ void InspectorBackendMojo::Connect() { // AgentRegistry used to do this, but we don't need it for one agent. script_manager_ = InjectedScriptManager::createForPage(); - debugger_agent_ = PageDebuggerAgent::create(&PageScriptDebugServer::shared(), &frame_host_.page(), script_manager_.get()); + debugger_agent_ = + PageDebuggerAgent::create(&PageScriptDebugServer::shared(), + &frame_host_.page(), script_manager_.get()); agents_ = adoptPtr(new InstrumentingAgents(debugger_agent_.get())); debugger_agent_->init(agents_.get(), inspector_state_.get()); debugger_agent_->setFrontend(old_frontend_.get()); @@ -101,7 +102,7 @@ void InspectorBackendMojo::OnMessage(const mojo::String& message) { // if agents are missing, since we only want this backend to care about // the Debugger agent, we manually filter here. if (command_name.startsWith("Debugger")) - dispatcher_->dispatch(wtf_message); + dispatcher_->dispatch(wtf_message); } -} // namespace blink +} // namespace blink diff --git a/engine/core/inspector/inspector_backend_mojo.h b/engine/v8_inspector/inspector_backend_mojo.h similarity index 95% rename from engine/core/inspector/inspector_backend_mojo.h rename to engine/v8_inspector/inspector_backend_mojo.h index ee0b7d8fb2d..666074bb64a 100644 --- a/engine/core/inspector/inspector_backend_mojo.h +++ b/engine/v8_inspector/inspector_backend_mojo.h @@ -20,14 +20,14 @@ class InstrumentingAgents; class InspectorFrontend; class InspectorBackendMojo : public mojo::InterfaceImpl, - public InspectorFrontendChannel { -public: + public InspectorFrontendChannel { + public: explicit InspectorBackendMojo(const FrameHost& frame_host); ~InspectorBackendMojo(); void Connect(); -private: + private: // InspectorBackend: void OnConnect() override; void OnDisconnect() override; diff --git a/engine/web/BUILD.gn b/engine/web/BUILD.gn index ccbe6dd9a79..fdc0528a5f1 100644 --- a/engine/web/BUILD.gn +++ b/engine/web/BUILD.gn @@ -25,6 +25,9 @@ component("web") { deps = [ "//sky/engine/core", "//sky/engine/platform", + # FIXME: v8_inspector should not depend on core types and be separate + # from both web and core. + "//sky/engine/v8_inspector", ] configs += [ diff --git a/engine/web/WebViewImpl.cpp b/engine/web/WebViewImpl.cpp index 670901c66c3..bd1506fb52e 100644 --- a/engine/web/WebViewImpl.cpp +++ b/engine/web/WebViewImpl.cpp @@ -51,7 +51,7 @@ #include "core/html/HTMLImportElement.h" #include "core/html/ime/InputMethodContext.h" #include "gen/sky/core/HTMLNames.h" -#include "core/inspector/inspector_backend_mojo.h" +#include "v8_inspector/inspector_backend_mojo.h" #include "core/loader/FrameLoader.h" #include "core/loader/UniqueIdentifier.h" #include "core/page/Chrome.h" diff --git a/engine/web/WebViewImpl.h b/engine/web/WebViewImpl.h index 6d834059bde..073f33bd3a7 100644 --- a/engine/web/WebViewImpl.h +++ b/engine/web/WebViewImpl.h @@ -32,7 +32,6 @@ #define WebViewImpl_h #include "core/html/ime/InputMethodContext.h" -#include "core/inspector/inspector_backend_mojo.h" #include "platform/geometry/IntPoint.h" #include "platform/geometry/IntRect.h" #include "platform/graphics/GraphicsLayer.h" @@ -63,6 +62,7 @@ class WebActiveGestureAnimation; class WebLocalFrameImpl; class WebImage; class WebSettingsImpl; +class InspectorBackendMojo; class WebViewImpl final : public WebView , public RefCounted @@ -451,6 +451,8 @@ private: bool m_userGestureObserved; + // FIXME(sky): InspectorBackendMojo should be a peer to WebView + // however right now it depends on acccess to the Page. OwnPtr m_inspectorBackend; };