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 "mojo/spy/spy.h" | 5 #include "mojo/spy/spy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 MojoResult last_result_; | 217 MojoResult last_result_; |
218 uint32_t bytes_transfered_; | 218 uint32_t bytes_transfered_; |
219 uint32_t message_count_[2]; | 219 uint32_t message_count_[2]; |
220 uint32_t handle_count_[2]; | 220 uint32_t handle_count_[2]; |
221 scoped_refptr<base::MessageLoopProxy> control_loop_proxy_; | 221 scoped_refptr<base::MessageLoopProxy> control_loop_proxy_; |
222 }; | 222 }; |
223 | 223 |
224 // In charge of intercepting access to the service manager. | 224 // In charge of intercepting access to the service manager. |
225 class SpyInterceptor : public mojo::ApplicationManager::Interceptor { | 225 class SpyInterceptor : public mojo::ApplicationManager::Interceptor { |
226 public: | 226 public: |
227 explicit SpyInterceptor(scoped_refptr<mojo::SpyServerImpl> spy_server, | 227 explicit SpyInterceptor( |
228 base::MessageLoopProxy* control_loop_proxy) | 228 scoped_refptr<mojo::SpyServerImpl> spy_server, |
| 229 const scoped_refptr<base::MessageLoopProxy>& control_loop_proxy) |
229 : spy_server_(spy_server), | 230 : spy_server_(spy_server), |
230 proxy_(base::MessageLoopProxy::current()), | 231 proxy_(base::MessageLoopProxy::current()), |
231 control_loop_proxy_(control_loop_proxy){ | 232 control_loop_proxy_(control_loop_proxy) {} |
232 } | |
233 | 233 |
234 private: | 234 private: |
235 virtual mojo::ServiceProviderPtr OnConnectToClient( | 235 virtual mojo::ServiceProviderPtr OnConnectToClient( |
236 const GURL& url, mojo::ServiceProviderPtr real_client) OVERRIDE { | 236 const GURL& url, mojo::ServiceProviderPtr real_client) OVERRIDE { |
237 if (!MustIntercept(url)) | 237 if (!MustIntercept(url)) |
238 return real_client.Pass(); | 238 return real_client.Pass(); |
239 | 239 |
240 // You can get an invalid handle if the app (or service) is | 240 // You can get an invalid handle if the app (or service) is |
241 // created by unconventional means, for example the command line. | 241 // created by unconventional means, for example the command line. |
242 if (!real_client) | 242 if (!real_client) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 application_manager->SetInterceptor( | 329 application_manager->SetInterceptor( |
330 new SpyInterceptor(spy_server_, control_thread_->message_loop_proxy())); | 330 new SpyInterceptor(spy_server_, control_thread_->message_loop_proxy())); |
331 } | 331 } |
332 | 332 |
333 Spy::~Spy() { | 333 Spy::~Spy() { |
334 // TODO(cpu): Do not leak the interceptor. Lifetime between the | 334 // TODO(cpu): Do not leak the interceptor. Lifetime between the |
335 // application_manager and the spy is still unclear hence the leak. | 335 // application_manager and the spy is still unclear hence the leak. |
336 } | 336 } |
337 | 337 |
338 } // namespace mojo | 338 } // namespace mojo |
OLD | NEW |