Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: mojo/spy/spy.cc

Issue 405653003: mojo: Make InterfacePtr<> testable in if() statements without .get(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to is_bound() Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/shell/dynamic_service_loader.cc ('k') | mojo/system/local_data_pipe.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « mojo/shell/dynamic_service_loader.cc ('k') | mojo/system/local_data_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698