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

Side by Side Diff: content/common/mojo/service_registry_impl.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix network_service_loader 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 | « no previous file | content/renderer/render_thread_impl.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 "content/common/mojo/service_registry_impl.h" 5 #include "content/common/mojo/service_registry_impl.h"
6 6
7 #include "mojo/common/common_type_converters.h" 7 #include "mojo/common/common_type_converters.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 ServiceRegistryImpl::ServiceRegistryImpl() : bound_(false) { 11 ServiceRegistryImpl::ServiceRegistryImpl() : bound_(false) {
12 } 12 }
13 13
14 ServiceRegistryImpl::ServiceRegistryImpl(mojo::ScopedMessagePipeHandle handle) 14 ServiceRegistryImpl::ServiceRegistryImpl(mojo::ScopedMessagePipeHandle handle)
15 : bound_(false) { 15 : bound_(false) {
16 BindRemoteServiceProvider(handle.Pass()); 16 BindRemoteServiceProvider(handle.Pass());
17 } 17 }
18 18
19 ServiceRegistryImpl::~ServiceRegistryImpl() { 19 ServiceRegistryImpl::~ServiceRegistryImpl() {
20 while (!pending_connects_.empty()) { 20 while (!pending_connects_.empty()) {
21 mojo::CloseRaw(pending_connects_.front().second); 21 mojo::CloseRaw(pending_connects_.front().second);
22 pending_connects_.pop(); 22 pending_connects_.pop();
23 } 23 }
24 } 24 }
25 25
26 void ServiceRegistryImpl::BindRemoteServiceProvider( 26 void ServiceRegistryImpl::BindRemoteServiceProvider(
27 mojo::ScopedMessagePipeHandle handle) { 27 mojo::ScopedMessagePipeHandle handle) {
28 DCHECK(!bound_); 28 DCHECK(!bound_);
29 bound_ = true; 29 bound_ = true;
30 mojo::BindToPipe(this, handle.Pass()); 30 mojo::WeakBindToPipe(this, handle.Pass());
31 while (!pending_connects_.empty()) { 31 while (!pending_connects_.empty()) {
32 client()->ConnectToService( 32 client()->ConnectToService(
33 mojo::String::From(pending_connects_.front().first), 33 mojo::String::From(pending_connects_.front().first),
34 mojo::ScopedMessagePipeHandle(pending_connects_.front().second)); 34 mojo::ScopedMessagePipeHandle(pending_connects_.front().second));
35 pending_connects_.pop(); 35 pending_connects_.pop();
36 } 36 }
37 } 37 }
38 38
39 void ServiceRegistryImpl::OnConnectionError() { 39 void ServiceRegistryImpl::OnConnectionError() {
40 // TODO(sammc): Support reporting this to our owner. 40 // TODO(sammc): Support reporting this to our owner.
(...skipping 28 matching lines...) Expand all
69 std::map<std::string, 69 std::map<std::string,
70 base::Callback<void(mojo::ScopedMessagePipeHandle)> >::iterator it = 70 base::Callback<void(mojo::ScopedMessagePipeHandle)> >::iterator it =
71 service_factories_.find(name); 71 service_factories_.find(name);
72 if (it == service_factories_.end()) 72 if (it == service_factories_.end())
73 return; 73 return;
74 74
75 it->second.Run(client_handle.Pass()); 75 it->second.Run(client_handle.Pass());
76 } 76 }
77 77
78 } // namespace content 78 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698