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

Side by Side Diff: sky/engine/v8_inspector/inspector_backend_mojo.cc

Issue 749523002: Move inspector_backend_mojo.cc to v8_inspector (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « sky/engine/v8_inspector/inspector_backend_mojo.h ('k') | sky/engine/web/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "sky/engine/config.h"
6 #include "core/inspector/inspector_backend_mojo.h" 6 #include "v8_inspector/inspector_backend_mojo.h"
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "bindings/core/v8/PageScriptDebugServer.h" 10 #include "bindings/core/v8/PageScriptDebugServer.h"
11 #include "bindings/core/v8/ScriptController.h" 11 #include "bindings/core/v8/ScriptController.h"
12 #include "core/frame/FrameHost.h"
13 #include "core/inspector/InspectorState.h"
14 #include "core/inspector/InstrumentingAgents.h"
15 #include "core/inspector/PageDebuggerAgent.h"
16 #include "core/page/Page.h"
17 #include "gen/sky/core/InspectorBackendDispatcher.h" 12 #include "gen/sky/core/InspectorBackendDispatcher.h"
18 #include "mojo/public/cpp/application/connect.h" 13 #include "mojo/public/cpp/application/connect.h"
19 #include "mojo/public/cpp/application/service_provider_impl.h" 14 #include "mojo/public/cpp/application/service_provider_impl.h"
20 #include "mojo/public/interfaces/application/shell.mojom.h" 15 #include "mojo/public/interfaces/application/shell.mojom.h"
21 #include "platform/JSONValues.h" 16 #include "sky/engine/core/frame/FrameHost.h"
22 #include "public/platform/ServiceProvider.h" 17 #include "sky/engine/core/inspector/InspectorState.h"
18 #include "sky/engine/core/inspector/InstrumentingAgents.h"
19 #include "sky/engine/core/inspector/PageDebuggerAgent.h"
20 #include "sky/engine/core/page/Page.h"
21 #include "sky/engine/platform/JSONValues.h"
22 #include "sky/engine/public/platform/ServiceProvider.h"
23 23
24 namespace blink { 24 namespace blink {
25 25
26 class MessageLoopAdaptor : public PageScriptDebugServer::ClientMessageLoop { 26 class MessageLoopAdaptor : public PageScriptDebugServer::ClientMessageLoop {
27 public: 27 public:
28 MessageLoopAdaptor() { } 28 MessageLoopAdaptor() {}
29 29
30 private: 30 private:
31 virtual void run(Page* page) 31 virtual void run(Page* page) {
32 { 32 run_loop_.reset(new base::RunLoop());
33 run_loop_.reset(new base::RunLoop()); 33 run_loop_->Run();
34 run_loop_->Run(); 34 }
35 }
36 35
37 virtual void quitNow() 36 virtual void quitNow() {
38 { 37 if (run_loop_)
39 if (run_loop_) 38 run_loop_->Quit();
40 run_loop_->Quit(); 39 }
41 }
42 40
43 scoped_ptr<base::RunLoop> run_loop_; 41 scoped_ptr<base::RunLoop> run_loop_;
44 }; 42 };
45 43
46 InspectorBackendMojo::InspectorBackendMojo(const FrameHost& frame_host) 44 InspectorBackendMojo::InspectorBackendMojo(const FrameHost& frame_host)
47 : frame_host_(frame_host) { 45 : frame_host_(frame_host) {
48 } 46 }
49 47
50 InspectorBackendMojo::~InspectorBackendMojo() { 48 InspectorBackendMojo::~InspectorBackendMojo() {
51 } 49 }
52 50
53 void InspectorBackendMojo::Connect() { 51 void InspectorBackendMojo::Connect() {
54 mojo::Shell* shell = frame_host_.services().Shell(); 52 mojo::Shell* shell = frame_host_.services().Shell();
55 mojo::ServiceProviderPtr inspector_service_provider; 53 mojo::ServiceProviderPtr inspector_service_provider;
56 shell->ConnectToApplication("mojo:sky_inspector_server", 54 shell->ConnectToApplication("mojo:sky_inspector_server",
57 GetProxy(&inspector_service_provider)); 55 GetProxy(&inspector_service_provider));
58 mojo::ConnectToService(inspector_service_provider.get(), &frontend_); 56 mojo::ConnectToService(inspector_service_provider.get(), &frontend_);
59 frontend_.set_client(this); 57 frontend_.set_client(this);
60 58
61 // Theoretically we should load our state from the inspector cookie. 59 // Theoretically we should load our state from the inspector cookie.
62 inspector_state_ = adoptPtr(new InspectorState(nullptr, JSONObject::create())) ; 60 inspector_state_ =
61 adoptPtr(new InspectorState(nullptr, JSONObject::create()));
63 old_frontend_ = adoptPtr(new InspectorFrontend(this)); 62 old_frontend_ = adoptPtr(new InspectorFrontend(this));
64 63
65 v8::Isolate* isolate = frame_host_.page().mainFrame()->script().isolate(); 64 v8::Isolate* isolate = frame_host_.page().mainFrame()->script().isolate();
66 PageScriptDebugServer::setMainThreadIsolate(isolate); 65 PageScriptDebugServer::setMainThreadIsolate(isolate);
67 OwnPtr<MessageLoopAdaptor> message_loop = adoptPtr(new MessageLoopAdaptor); 66 OwnPtr<MessageLoopAdaptor> message_loop = adoptPtr(new MessageLoopAdaptor);
68 PageScriptDebugServer::shared().setClientMessageLoop(message_loop.release()); 67 PageScriptDebugServer::shared().setClientMessageLoop(message_loop.release());
69 68
70 // AgentRegistry used to do this, but we don't need it for one agent. 69 // AgentRegistry used to do this, but we don't need it for one agent.
71 script_manager_ = InjectedScriptManager::createForPage(); 70 script_manager_ = InjectedScriptManager::createForPage();
72 debugger_agent_ = PageDebuggerAgent::create(&PageScriptDebugServer::shared(), &frame_host_.page(), script_manager_.get()); 71 debugger_agent_ =
72 PageDebuggerAgent::create(&PageScriptDebugServer::shared(),
73 &frame_host_.page(), script_manager_.get());
73 agents_ = adoptPtr(new InstrumentingAgents(debugger_agent_.get())); 74 agents_ = adoptPtr(new InstrumentingAgents(debugger_agent_.get()));
74 debugger_agent_->init(agents_.get(), inspector_state_.get()); 75 debugger_agent_->init(agents_.get(), inspector_state_.get());
75 debugger_agent_->setFrontend(old_frontend_.get()); 76 debugger_agent_->setFrontend(old_frontend_.get());
76 77
77 dispatcher_ = InspectorBackendDispatcher::create(this); 78 dispatcher_ = InspectorBackendDispatcher::create(this);
78 dispatcher_->registerAgent(debugger_agent_.get()); 79 dispatcher_->registerAgent(debugger_agent_.get());
79 } 80 }
80 81
81 void InspectorBackendMojo::sendMessageToFrontend( 82 void InspectorBackendMojo::sendMessageToFrontend(
82 PassRefPtr<JSONObject> message) { 83 PassRefPtr<JSONObject> message) {
(...skipping 11 matching lines...) Expand all
94 } 95 }
95 96
96 void InspectorBackendMojo::OnMessage(const mojo::String& message) { 97 void InspectorBackendMojo::OnMessage(const mojo::String& message) {
97 String wtf_message = String::fromUTF8(message.To<std::string>()); 98 String wtf_message = String::fromUTF8(message.To<std::string>());
98 String command_name; 99 String command_name;
99 InspectorBackendDispatcher::getCommandName(wtf_message, &command_name); 100 InspectorBackendDispatcher::getCommandName(wtf_message, &command_name);
100 // InspectorBackendDispatcher will automatically reply with errors 101 // InspectorBackendDispatcher will automatically reply with errors
101 // if agents are missing, since we only want this backend to care about 102 // if agents are missing, since we only want this backend to care about
102 // the Debugger agent, we manually filter here. 103 // the Debugger agent, we manually filter here.
103 if (command_name.startsWith("Debugger")) 104 if (command_name.startsWith("Debugger"))
104 dispatcher_->dispatch(wtf_message); 105 dispatcher_->dispatch(wtf_message);
105 } 106 }
106 107
107 } // namespace blink 108 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/v8_inspector/inspector_backend_mojo.h ('k') | sky/engine/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698