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

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

Issue 1128493002: Add connection error handing in ServiceRegistryImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 7 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') | no next file » | 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() 11 ServiceRegistryImpl::ServiceRegistryImpl()
12 : binding_(this), weak_factory_(this) { 12 : binding_(this), weak_factory_(this) {
13 binding_.set_error_handler(this);
13 } 14 }
14 15
15 ServiceRegistryImpl::~ServiceRegistryImpl() { 16 ServiceRegistryImpl::~ServiceRegistryImpl() {
16 while (!pending_connects_.empty()) { 17 while (!pending_connects_.empty()) {
17 mojo::CloseRaw(pending_connects_.front().second); 18 mojo::CloseRaw(pending_connects_.front().second);
18 pending_connects_.pop(); 19 pending_connects_.pop();
19 } 20 }
20 } 21 }
21 22
22 void ServiceRegistryImpl::Bind( 23 void ServiceRegistryImpl::Bind(
(...skipping 28 matching lines...) Expand all
51 mojo::ScopedMessagePipeHandle handle) { 52 mojo::ScopedMessagePipeHandle handle) {
52 if (!remote_provider_) { 53 if (!remote_provider_) {
53 pending_connects_.push( 54 pending_connects_.push(
54 std::make_pair(service_name.as_string(), handle.release())); 55 std::make_pair(service_name.as_string(), handle.release()));
55 return; 56 return;
56 } 57 }
57 remote_provider_->ConnectToService(mojo::String::From(service_name), 58 remote_provider_->ConnectToService(mojo::String::From(service_name),
58 handle.Pass()); 59 handle.Pass());
59 } 60 }
60 61
62 bool ServiceRegistryImpl::IsBound() const {
63 return binding_.is_bound();
64 }
65
61 base::WeakPtr<ServiceRegistry> ServiceRegistryImpl::GetWeakPtr() { 66 base::WeakPtr<ServiceRegistry> ServiceRegistryImpl::GetWeakPtr() {
62 return weak_factory_.GetWeakPtr(); 67 return weak_factory_.GetWeakPtr();
63 } 68 }
64 69
65 void ServiceRegistryImpl::ConnectToService( 70 void ServiceRegistryImpl::ConnectToService(
66 const mojo::String& name, 71 const mojo::String& name,
67 mojo::ScopedMessagePipeHandle client_handle) { 72 mojo::ScopedMessagePipeHandle client_handle) {
68 std::map<std::string, 73 std::map<std::string,
69 base::Callback<void(mojo::ScopedMessagePipeHandle)> >::iterator it = 74 base::Callback<void(mojo::ScopedMessagePipeHandle)> >::iterator it =
70 service_factories_.find(name); 75 service_factories_.find(name);
71 if (it == service_factories_.end()) 76 if (it == service_factories_.end())
72 return; 77 return;
73 78
74 it->second.Run(client_handle.Pass()); 79 it->second.Run(client_handle.Pass());
75 } 80 }
76 81
82 void ServiceRegistryImpl::OnConnectionError() {
83 binding_.Close();
84 }
85
77 } // namespace content 86 } // namespace content
OLDNEW
« no previous file with comments | « content/common/mojo/service_registry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698