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

Side by Side Diff: services/service_manager/public/cpp/binder_registry.cc

Issue 2859343003: Enable overriding interface binders for any services running in current process. (Closed)
Patch Set: Address nit Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/service_manager/public/cpp/binder_registry.h" 5 #include "services/service_manager/public/cpp/binder_registry.h"
6 6
7 #include "services/service_manager/public/cpp/identity.h" 7 #include "services/service_manager/public/cpp/identity.h"
8 8
9 namespace service_manager { 9 namespace service_manager {
10 10
11 BinderRegistry::BinderRegistry() : weak_factory_(this) {} 11 BinderRegistry::BinderRegistry() : weak_factory_(this) {}
12 BinderRegistry::~BinderRegistry() {} 12 BinderRegistry::~BinderRegistry() {}
13 13
14 void BinderRegistry::AddInterface( 14 void BinderRegistry::AddInterface(
15 const std::string& interface_name, 15 const std::string& interface_name,
16 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback, 16 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback,
17 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 17 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
18 SetInterfaceBinder(interface_name, base::MakeUnique<GenericCallbackBinder>( 18 SetInterfaceBinder(interface_name, base::MakeUnique<GenericCallbackBinder>(
19 callback, task_runner)); 19 callback, task_runner));
20 } 20 }
21 21
22 void BinderRegistry::AddInterface(
23 const std::string& interface_name,
24 const Binder& binder_callback,
25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
26 SetInterfaceBinder(interface_name, base::MakeUnique<GenericCallbackBinder>(
27 binder_callback, task_runner));
28 }
29
22 void BinderRegistry::RemoveInterface(const std::string& interface_name) { 30 void BinderRegistry::RemoveInterface(const std::string& interface_name) {
23 auto it = binders_.find(interface_name); 31 auto it = binders_.find(interface_name);
24 if (it != binders_.end()) 32 if (it != binders_.end())
25 binders_.erase(it); 33 binders_.erase(it);
26 } 34 }
27 35
28 bool BinderRegistry::CanBindInterface(const std::string& interface_name) const { 36 bool BinderRegistry::CanBindInterface(const std::string& interface_name) const {
29 auto it = binders_.find(interface_name); 37 auto it = binders_.find(interface_name);
30 return it != binders_.end(); 38 return it != binders_.end();
31 } 39 }
(...skipping 16 matching lines...) Expand all
48 } 56 }
49 57
50 void BinderRegistry::SetInterfaceBinder( 58 void BinderRegistry::SetInterfaceBinder(
51 const std::string& interface_name, 59 const std::string& interface_name,
52 std::unique_ptr<InterfaceBinder> binder) { 60 std::unique_ptr<InterfaceBinder> binder) {
53 RemoveInterface(interface_name); 61 RemoveInterface(interface_name);
54 binders_[interface_name] = std::move(binder); 62 binders_[interface_name] = std::move(binder);
55 } 63 }
56 64
57 } // namespace service_manager 65 } // namespace service_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698