| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 public: | 226 public: |
| 227 explicit SpyInterceptor( | 227 explicit SpyInterceptor( |
| 228 scoped_refptr<mojo::SpyServerImpl> spy_server, | 228 scoped_refptr<mojo::SpyServerImpl> spy_server, |
| 229 const scoped_refptr<base::MessageLoopProxy>& control_loop_proxy) | 229 const scoped_refptr<base::MessageLoopProxy>& control_loop_proxy) |
| 230 : spy_server_(spy_server), | 230 : spy_server_(spy_server), |
| 231 proxy_(base::MessageLoopProxy::current()), | 231 proxy_(base::MessageLoopProxy::current()), |
| 232 control_loop_proxy_(control_loop_proxy) {} | 232 control_loop_proxy_(control_loop_proxy) {} |
| 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) |
| 243 return real_client.Pass(); | 243 return real_client.Pass(); |
| 244 | 244 |
| 245 mojo::ScopedMessagePipeHandle faux_client; | 245 mojo::ScopedMessagePipeHandle faux_client; |
| 246 mojo::ScopedMessagePipeHandle interceptor; | 246 mojo::ScopedMessagePipeHandle interceptor; |
| (...skipping 82 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 |