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

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

Issue 2860023002: Eliminate lib directory for service manager client lib. (Closed)
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "services/service_manager/public/cpp/binder_registry.h"
6
7 #include "services/service_manager/public/cpp/identity.h"
8
9 namespace service_manager {
10
11 BinderRegistry::BinderRegistry() : weak_factory_(this) {}
12 BinderRegistry::~BinderRegistry() {}
13
14 void BinderRegistry::AddInterface(
15 const std::string& interface_name,
16 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback,
17 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
18 SetInterfaceBinder(interface_name, base::MakeUnique<GenericCallbackBinder>(
19 callback, task_runner));
20 }
21
22 void BinderRegistry::RemoveInterface(const std::string& interface_name) {
23 auto it = binders_.find(interface_name);
24 if (it != binders_.end())
25 binders_.erase(it);
26 }
27
28 bool BinderRegistry::CanBindInterface(const std::string& interface_name) const {
29 auto it = binders_.find(interface_name);
30 return it != binders_.end();
31 }
32
33 void BinderRegistry::BindInterface(
34 const BindSourceInfo& source_info,
35 const std::string& interface_name,
36 mojo::ScopedMessagePipeHandle interface_pipe) {
37 auto it = binders_.find(interface_name);
38 if (it != binders_.end()) {
39 it->second->BindInterface(source_info, interface_name,
40 std::move(interface_pipe));
41 } else {
42 LOG(ERROR) << "Failed to locate a binder for interface: " << interface_name;
43 }
44 }
45
46 base::WeakPtr<BinderRegistry> BinderRegistry::GetWeakPtr() {
47 return weak_factory_.GetWeakPtr();
48 }
49
50 void BinderRegistry::SetInterfaceBinder(
51 const std::string& interface_name,
52 std::unique_ptr<InterfaceBinder> binder) {
53 RemoveInterface(interface_name);
54 binders_[interface_name] = std::move(binder);
55 }
56
57 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/public/cpp/lib/bind_source_info.cc ('k') | services/service_manager/public/cpp/lib/identity.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698