Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "shell/context.h" | 5 #include "shell/context.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 const GURL to(pair.second); | 107 const GURL to(pair.second); |
| 108 if (!from.is_valid() || !to.is_valid()) | 108 if (!from.is_valid() || !to.is_valid()) |
| 109 return false; | 109 return false; |
| 110 resolver->AddCustomMapping(from, to); | 110 resolver->AddCustomMapping(from, to); |
| 111 } | 111 } |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace | 115 } // namespace |
| 116 | 116 |
| 117 class Context::TracingServiceProvider : public ServiceProvider { | |
| 118 public: | |
| 119 explicit TracingServiceProvider(ScopedMessagePipeHandle handle) | |
| 120 : binding_(this, handle.Pass()) {} | |
| 121 ~TracingServiceProvider() override {} | |
| 122 | |
| 123 void ConnectToService(const mojo::String& service_name, | |
| 124 ScopedMessagePipeHandle client_handle) override { | |
| 125 if (service_name != tracing::TraceController::Name_) { | |
| 126 client_handle.reset(); | |
| 127 return; | |
| 128 } | |
| 129 trace_controller_.Bind(client_handle.Pass()); | |
| 130 } | |
| 131 | |
| 132 private: | |
| 133 TraceControllerImpl trace_controller_; | |
| 134 StrongBinding<ServiceProvider> binding_; | |
|
qsr
2014/12/19 09:47:14
I might be missing something, but if I understand
jamesr
2014/12/29 18:57:58
You are correct. I'll get rid of the scoped_ptr (
| |
| 135 }; | |
| 136 | |
| 117 Context::Context() : application_manager_(this) { | 137 Context::Context() : application_manager_(this) { |
| 118 DCHECK(!base::MessageLoop::current()); | 138 DCHECK(!base::MessageLoop::current()); |
| 119 } | 139 } |
| 120 | 140 |
| 121 Context::~Context() { | 141 Context::~Context() { |
| 122 DCHECK(!base::MessageLoop::current()); | 142 DCHECK(!base::MessageLoop::current()); |
| 123 } | 143 } |
| 124 | 144 |
| 125 void Context::EnsureEmbedderIsInitialized() { | 145 void Context::EnsureEmbedderIsInitialized() { |
| 126 setup.Get(); | 146 setup.Get(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 | 195 |
| 176 if (command_line->HasSwitch(switches::kSpy)) { | 196 if (command_line->HasSwitch(switches::kSpy)) { |
| 177 spy_.reset( | 197 spy_.reset( |
| 178 new mojo::Spy(&application_manager_, | 198 new mojo::Spy(&application_manager_, |
| 179 command_line->GetSwitchValueASCII(switches::kSpy))); | 199 command_line->GetSwitchValueASCII(switches::kSpy))); |
| 180 // TODO(cpu): the spy can snoop, but can't tell anybody until | 200 // TODO(cpu): the spy can snoop, but can't tell anybody until |
| 181 // the Spy::WebSocketDelegate is implemented. In the original repo this | 201 // the Spy::WebSocketDelegate is implemented. In the original repo this |
| 182 // was implemented by src\mojo\spy\websocket_server.h and .cc. | 202 // was implemented by src\mojo\spy\websocket_server.h and .cc. |
| 183 } | 203 } |
| 184 | 204 |
| 185 tracing::TraceDataCollectorPtr trace_data_collector_ptr; | 205 MessagePipe pipe; |
| 186 application_manager_.ConnectToService(GURL("mojo:tracing"), | 206 ServiceProviderPtr spp; |
| 187 &trace_data_collector_ptr); | 207 tracing_sp_.reset(new Context::TracingServiceProvider(pipe.handle0.Pass())); |
| 188 TracingImpl::Create(trace_data_collector_ptr.Pass()); | 208 spp.Bind(pipe.handle1.Pass()); |
|
qsr
2014/12/19 09:47:14
Did we lose the ability to bury the pipes with the
jamesr
2014/12/29 18:57:58
I think hiding these makes this code a lot harder
qsr
2015/01/05 13:38:31
Hum... Ok, I have a tendency to think the opposite
| |
| 209 application_manager_.ConnectToApplication(GURL("mojo:tracing"), GURL(""), | |
| 210 spp.Pass()); | |
| 189 | 211 |
| 190 if (listener_) | 212 if (listener_) |
| 191 listener_->WaitForListening(); | 213 listener_->WaitForListening(); |
| 192 | 214 |
| 193 return true; | 215 return true; |
| 194 } | 216 } |
| 195 | 217 |
| 196 void Context::OnApplicationError(const GURL& url) { | 218 void Context::OnApplicationError(const GURL& url) { |
| 197 if (app_urls_.find(url) != app_urls_.end()) { | 219 if (app_urls_.find(url) != app_urls_.end()) { |
| 198 app_urls_.erase(url); | 220 app_urls_.erase(url); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 217 ScopedMessagePipeHandle Context::ConnectToServiceByName( | 239 ScopedMessagePipeHandle Context::ConnectToServiceByName( |
| 218 const GURL& application_url, | 240 const GURL& application_url, |
| 219 const std::string& service_name) { | 241 const std::string& service_name) { |
| 220 app_urls_.insert(application_url); | 242 app_urls_.insert(application_url); |
| 221 return application_manager_.ConnectToServiceByName(application_url, | 243 return application_manager_.ConnectToServiceByName(application_url, |
| 222 service_name).Pass(); | 244 service_name).Pass(); |
| 223 } | 245 } |
| 224 | 246 |
| 225 } // namespace shell | 247 } // namespace shell |
| 226 } // namespace mojo | 248 } // namespace mojo |
| OLD | NEW |