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

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

Issue 302573002: Add a Javascript wrapper around ServiceRegistry and expose it to WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render-view-shell
Patch Set: address comments Created 6 years, 4 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
« no previous file with comments | « content/common/mojo/service_registry_impl.h ('k') | content/content_renderer.gypi » ('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()
12 : bound_(false), weak_factory_(this) {
12 } 13 }
13 14
14 ServiceRegistryImpl::ServiceRegistryImpl(mojo::ScopedMessagePipeHandle handle) 15 ServiceRegistryImpl::ServiceRegistryImpl(mojo::ScopedMessagePipeHandle handle)
15 : bound_(false) { 16 : bound_(false), weak_factory_(this) {
16 BindRemoteServiceProvider(handle.Pass()); 17 BindRemoteServiceProvider(handle.Pass());
17 } 18 }
18 19
19 ServiceRegistryImpl::~ServiceRegistryImpl() { 20 ServiceRegistryImpl::~ServiceRegistryImpl() {
20 while (!pending_connects_.empty()) { 21 while (!pending_connects_.empty()) {
21 mojo::CloseRaw(pending_connects_.front().second); 22 mojo::CloseRaw(pending_connects_.front().second);
22 pending_connects_.pop(); 23 pending_connects_.pop();
23 } 24 }
24 } 25 }
25 26
(...skipping 30 matching lines...) Expand all
56 const base::StringPiece& service_name, 57 const base::StringPiece& service_name,
57 mojo::ScopedMessagePipeHandle handle) { 58 mojo::ScopedMessagePipeHandle handle) {
58 if (!bound_) { 59 if (!bound_) {
59 pending_connects_.push( 60 pending_connects_.push(
60 std::make_pair(service_name.as_string(), handle.release())); 61 std::make_pair(service_name.as_string(), handle.release()));
61 return; 62 return;
62 } 63 }
63 client()->ConnectToService(mojo::String::From(service_name), handle.Pass()); 64 client()->ConnectToService(mojo::String::From(service_name), handle.Pass());
64 } 65 }
65 66
67 base::WeakPtr<ServiceRegistry> ServiceRegistryImpl::GetWeakPtr() {
68 return weak_factory_.GetWeakPtr();
69 }
70
66 void ServiceRegistryImpl::ConnectToService( 71 void ServiceRegistryImpl::ConnectToService(
67 const mojo::String& name, 72 const mojo::String& name,
68 mojo::ScopedMessagePipeHandle client_handle) { 73 mojo::ScopedMessagePipeHandle client_handle) {
69 std::map<std::string, 74 std::map<std::string,
70 base::Callback<void(mojo::ScopedMessagePipeHandle)> >::iterator it = 75 base::Callback<void(mojo::ScopedMessagePipeHandle)> >::iterator it =
71 service_factories_.find(name); 76 service_factories_.find(name);
72 if (it == service_factories_.end()) 77 if (it == service_factories_.end())
73 return; 78 return;
74 79
75 it->second.Run(client_handle.Pass()); 80 it->second.Run(client_handle.Pass());
76 } 81 }
77 82
78 } // namespace content 83 } // namespace content
OLDNEW
« no previous file with comments | « content/common/mojo/service_registry_impl.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698