| OLD | NEW |
| 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/v8_inspector/inspector_backend_mojo.h" | 6 #include "sky/engine/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 "gen/sky/core/InspectorBackendDispatcher.h" | 10 #include "gen/sky/core/InspectorBackendDispatcher.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual void quitNow() { | 67 virtual void quitNow() { |
| 68 if (run_loop_) | 68 if (run_loop_) |
| 69 run_loop_->Quit(); | 69 run_loop_->Quit(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 scoped_ptr<base::RunLoop> run_loop_; | 72 scoped_ptr<base::RunLoop> run_loop_; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class InspectorHostResolverImpl : public PageScriptDebugServer::InspectorHostRes
olver { |
| 76 public: |
| 77 explicit InspectorHostResolverImpl(inspector::InspectorHost* host) : host_(hos
t) { } |
| 78 ~InspectorHostResolverImpl() override { } |
| 79 inspector::InspectorHost* inspectorHostFor(v8::Handle<v8::Context> context) ov
erride { |
| 80 if (context == host_->GetContext()) |
| 81 return host_; |
| 82 return nullptr; |
| 83 } |
| 84 private: |
| 85 inspector::InspectorHost* host_; |
| 86 }; |
| 87 |
| 75 InspectorBackendMojoImpl::InspectorBackendMojoImpl( | 88 InspectorBackendMojoImpl::InspectorBackendMojoImpl( |
| 76 inspector::InspectorHost* host) | 89 inspector::InspectorHost* host) |
| 77 : host_(host) { | 90 : host_(host) { |
| 78 } | 91 } |
| 79 | 92 |
| 80 InspectorBackendMojoImpl::~InspectorBackendMojoImpl() { | 93 InspectorBackendMojoImpl::~InspectorBackendMojoImpl() { |
| 81 } | 94 } |
| 82 | 95 |
| 83 void InspectorBackendMojoImpl::Connect() { | 96 void InspectorBackendMojoImpl::Connect() { |
| 84 mojo::Shell* shell = host_->GetShell(); | 97 mojo::Shell* shell = host_->GetShell(); |
| 85 mojo::ServiceProviderPtr inspector_service_provider; | 98 mojo::ServiceProviderPtr inspector_service_provider; |
| 86 shell->ConnectToApplication("mojo:sky_inspector_server", | 99 shell->ConnectToApplication("mojo:sky_inspector_server", |
| 87 GetProxy(&inspector_service_provider)); | 100 GetProxy(&inspector_service_provider)); |
| 88 mojo::ConnectToService(inspector_service_provider.get(), &frontend_); | 101 mojo::ConnectToService(inspector_service_provider.get(), &frontend_); |
| 89 frontend_.set_client(this); | 102 frontend_.set_client(this); |
| 90 | 103 |
| 91 // Theoretically we should load our state from the inspector cookie. | 104 // Theoretically we should load our state from the inspector cookie. |
| 92 inspector_state_ = | 105 inspector_state_ = |
| 93 adoptPtr(new InspectorState(nullptr, JSONObject::create())); | 106 adoptPtr(new InspectorState(nullptr, JSONObject::create())); |
| 94 old_frontend_ = adoptPtr(new InspectorFrontend(this)); | 107 old_frontend_ = adoptPtr(new InspectorFrontend(this)); |
| 95 | 108 |
| 96 PageScriptDebugServer::setMainThreadIsolate(host_->GetIsolate()); | 109 PageScriptDebugServer::setMainThreadIsolate(host_->GetIsolate()); |
| 97 OwnPtr<MessageLoopAdaptor> message_loop = adoptPtr(new MessageLoopAdaptor); | 110 OwnPtr<MessageLoopAdaptor> message_loop = adoptPtr(new MessageLoopAdaptor); |
| 98 PageScriptDebugServer::shared().setClientMessageLoop(message_loop.release()); | 111 PageScriptDebugServer::shared().setClientMessageLoop(message_loop.release()); |
| 112 OwnPtr<InspectorHostResolverImpl> host_resolver = |
| 113 adoptPtr(new InspectorHostResolverImpl(host_)); |
| 114 PageScriptDebugServer::shared().setInspectorHostResolver(host_resolver.release
()); |
| 99 | 115 |
| 100 // AgentRegistry used to do this, but we don't need it for one agent. | 116 // AgentRegistry used to do this, but we don't need it for one agent. |
| 101 script_manager_ = InjectedScriptManager::createForPage(); | 117 script_manager_ = InjectedScriptManager::createForPage(); |
| 102 debugger_agent_ = PageDebuggerAgent::create(&PageScriptDebugServer::shared(), | 118 debugger_agent_ = PageDebuggerAgent::create(&PageScriptDebugServer::shared(), |
| 103 host_, script_manager_.get()); | 119 host_, script_manager_.get()); |
| 104 agents_ = adoptPtr(new InstrumentingAgents(debugger_agent_.get())); | 120 agents_ = adoptPtr(new InstrumentingAgents(debugger_agent_.get())); |
| 105 debugger_agent_->init(agents_.get(), inspector_state_.get()); | 121 debugger_agent_->init(agents_.get(), inspector_state_.get()); |
| 106 debugger_agent_->setFrontend(old_frontend_.get()); | 122 debugger_agent_->setFrontend(old_frontend_.get()); |
| 107 | 123 |
| 108 dispatcher_ = InspectorBackendDispatcher::create(this); | 124 dispatcher_ = InspectorBackendDispatcher::create(this); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 156 } |
| 141 | 157 |
| 142 InspectorBackendMojo::~InspectorBackendMojo() { | 158 InspectorBackendMojo::~InspectorBackendMojo() { |
| 143 } | 159 } |
| 144 | 160 |
| 145 void InspectorBackendMojo::Connect() { | 161 void InspectorBackendMojo::Connect() { |
| 146 impl_->Connect(); | 162 impl_->Connect(); |
| 147 } | 163 } |
| 148 | 164 |
| 149 } // namespace inspector | 165 } // namespace inspector |
| OLD | NEW |