| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (!MustIntercept(url)) | 131 if (!MustIntercept(url)) |
| 132 return real_client.Pass(); | 132 return real_client.Pass(); |
| 133 | 133 |
| 134 // You can get an invalid handle if the app (or service) is | 134 // You can get an invalid handle if the app (or service) is |
| 135 // created by unconventional means, for example the command line. | 135 // created by unconventional means, for example the command line. |
| 136 if (!real_client.is_valid()) | 136 if (!real_client.is_valid()) |
| 137 return real_client.Pass(); | 137 return real_client.Pass(); |
| 138 | 138 |
| 139 mojo::ScopedMessagePipeHandle faux_client; | 139 mojo::ScopedMessagePipeHandle faux_client; |
| 140 mojo::ScopedMessagePipeHandle interceptor; | 140 mojo::ScopedMessagePipeHandle interceptor; |
| 141 CreateMessagePipe(&faux_client, &interceptor); | 141 CreateMessagePipe(NULL, &faux_client, &interceptor); |
| 142 | 142 |
| 143 scoped_refptr<MessageProcessor> processor = new MessageProcessor(); | 143 scoped_refptr<MessageProcessor> processor = new MessageProcessor(); |
| 144 base::WorkerPool::PostTask( | 144 base::WorkerPool::PostTask( |
| 145 FROM_HERE, | 145 FROM_HERE, |
| 146 base::Bind(&MessageProcessor::Start, | 146 base::Bind(&MessageProcessor::Start, |
| 147 processor, | 147 processor, |
| 148 base::Passed(&real_client), base::Passed(&interceptor)), | 148 base::Passed(&real_client), base::Passed(&interceptor)), |
| 149 true); | 149 true); |
| 150 | 150 |
| 151 return faux_client.Pass(); | 151 return faux_client.Pass(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // Start intercepting mojo services. | 206 // Start intercepting mojo services. |
| 207 service_manager->SetInterceptor(new SpyInterceptor()); | 207 service_manager->SetInterceptor(new SpyInterceptor()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 Spy::~Spy(){ | 210 Spy::~Spy(){ |
| 211 // TODO(cpu): Do not leak the interceptor. Lifetime between the | 211 // TODO(cpu): Do not leak the interceptor. Lifetime between the |
| 212 // service_manager and the spy is still unclear hence the leak. | 212 // service_manager and the spy is still unclear hence the leak. |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace mojo | 215 } // namespace mojo |
| OLD | NEW |