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

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

Issue 2860943002: Flatten interface_binder.h and callback_binder.h (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
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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "mojo/public/cpp/system/message_pipe.h" 15 #include "mojo/public/cpp/system/message_pipe.h"
16 #include "services/service_manager/public/cpp/lib/callback_binder.h" 16 #include "services/service_manager/public/cpp/interface_binder.h"
17 17
18 namespace service_manager { 18 namespace service_manager {
19 19
20 class InterfaceBinder; 20 class InterfaceBinder;
21 struct BindSourceInfo; 21 struct BindSourceInfo;
22 22
23 class BinderRegistry { 23 class BinderRegistry {
24 public: 24 public:
25 using Binder = base::Callback<void(const std::string&, 25 using Binder = base::Callback<void(const std::string&,
26 mojo::ScopedMessagePipeHandle)>; 26 mojo::ScopedMessagePipeHandle)>;
27 27
28 BinderRegistry(); 28 BinderRegistry();
29 ~BinderRegistry(); 29 ~BinderRegistry();
30 30
31 template <typename Interface> 31 template <typename Interface>
32 void AddInterface( 32 void AddInterface(
33 const base::Callback<void(const BindSourceInfo&, 33 const base::Callback<void(const BindSourceInfo&,
34 mojo::InterfaceRequest<Interface>)>& callback, 34 mojo::InterfaceRequest<Interface>)>& callback,
35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = 35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner =
36 nullptr) { 36 nullptr) {
37 SetInterfaceBinder(Interface::Name_, 37 SetInterfaceBinder(
38 base::MakeUnique<internal::CallbackBinder<Interface>>( 38 Interface::Name_,
39 callback, task_runner)); 39 base::MakeUnique<CallbackBinder<Interface>>(callback, task_runner));
40 } 40 }
41 void AddInterface( 41 void AddInterface(
42 const std::string& interface_name, 42 const std::string& interface_name,
43 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback, 43 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback,
44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = nullptr); 44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = nullptr);
45 45
46 // Removes the specified interface from the registry. This has no effect on 46 // Removes the specified interface from the registry. This has no effect on
47 // bindings already completed. 47 // bindings already completed.
48 template <typename Interface> 48 template <typename Interface>
49 void RemoveInterface() { 49 void RemoveInterface() {
(...skipping 24 matching lines...) Expand all
74 74
75 base::WeakPtrFactory<BinderRegistry> weak_factory_; 75 base::WeakPtrFactory<BinderRegistry> weak_factory_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(BinderRegistry); 77 DISALLOW_COPY_AND_ASSIGN(BinderRegistry);
78 }; 78 };
79 79
80 80
81 } // namespace service_manager 81 } // namespace service_manager
82 82
83 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ 83 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_
OLDNEW
« no previous file with comments | « services/service_manager/public/cpp/BUILD.gn ('k') | services/service_manager/public/cpp/interface_binder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698