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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 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.get()) | 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; |
247 CreateMessagePipe(NULL, &faux_client, &interceptor); | 247 CreateMessagePipe(NULL, &faux_client, &interceptor); |
248 | 248 |
249 scoped_refptr<MessageProcessor> processor = new MessageProcessor( | 249 scoped_refptr<MessageProcessor> processor = new MessageProcessor( |
250 control_loop_proxy_); | 250 control_loop_proxy_); |
251 mojo::ScopedMessagePipeHandle real_handle = real_client.PassMessagePipe(); | 251 mojo::ScopedMessagePipeHandle real_handle = real_client.PassMessagePipe(); |
252 base::WorkerPool::PostTask( | 252 base::WorkerPool::PostTask( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 service_manager->SetInterceptor(new SpyInterceptor( | 328 service_manager->SetInterceptor(new SpyInterceptor( |
329 spy_server_, control_thread_->message_loop_proxy())); | 329 spy_server_, control_thread_->message_loop_proxy())); |
330 } | 330 } |
331 | 331 |
332 Spy::~Spy() { | 332 Spy::~Spy() { |
333 // TODO(cpu): Do not leak the interceptor. Lifetime between the | 333 // TODO(cpu): Do not leak the interceptor. Lifetime between the |
334 // service_manager and the spy is still unclear hence the leak. | 334 // service_manager and the spy is still unclear hence the leak. |
335 } | 335 } |
336 | 336 |
337 } // namespace mojo | 337 } // namespace mojo |
OLD | NEW |