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

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

Issue 2879843002: Reland 1: Enable overriding interface binders for any services running in current process. (Closed)
Patch Set: Identical with original CL 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
« no previous file with comments | « content/test/BUILD.gn ('k') | services/service_manager/public/cpp/binder_registry.cc » ('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 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/export.h" 16 #include "services/service_manager/public/cpp/export.h"
17 #include "services/service_manager/public/cpp/interface_binder.h" 17 #include "services/service_manager/public/cpp/interface_binder.h"
18 18
19 namespace service_manager { 19 namespace service_manager {
20 20
21 class InterfaceBinder;
22 struct BindSourceInfo; 21 struct BindSourceInfo;
23 22
24 class SERVICE_MANAGER_PUBLIC_CPP_EXPORT BinderRegistry { 23 class SERVICE_MANAGER_PUBLIC_CPP_EXPORT BinderRegistry {
25 public: 24 public:
26 using Binder = base::Callback<void(const std::string&, 25 using Binder = base::Callback<void(const BindSourceInfo&,
27 mojo::ScopedMessagePipeHandle)>; 26 const std::string&,
27 mojo::ScopedMessagePipeHandle)>;
28 28
29 BinderRegistry(); 29 BinderRegistry();
30 ~BinderRegistry(); 30 ~BinderRegistry();
31 31
32 template <typename Interface> 32 template <typename Interface>
33 void AddInterface( 33 void AddInterface(
34 const base::Callback<void(const BindSourceInfo&, 34 const base::Callback<void(const BindSourceInfo&,
35 mojo::InterfaceRequest<Interface>)>& callback, 35 mojo::InterfaceRequest<Interface>)>& callback,
36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = 36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner =
37 nullptr) { 37 nullptr) {
38 SetInterfaceBinder( 38 SetInterfaceBinder(
39 Interface::Name_, 39 Interface::Name_,
40 base::MakeUnique<CallbackBinder<Interface>>(callback, task_runner)); 40 base::MakeUnique<CallbackBinder<Interface>>(callback, task_runner));
41 } 41 }
42 void AddInterface( 42 void AddInterface(
43 const std::string& interface_name, 43 const std::string& interface_name,
44 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback, 44 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback,
45 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = nullptr); 45 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = nullptr);
46 46
47 void AddInterface(
48 const std::string& interface_name,
49 const Binder& binder_callback,
50 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = nullptr);
51
47 // Removes the specified interface from the registry. This has no effect on 52 // Removes the specified interface from the registry. This has no effect on
48 // bindings already completed. 53 // bindings already completed.
49 template <typename Interface> 54 template <typename Interface>
50 void RemoveInterface() { 55 void RemoveInterface() {
51 RemoveInterface(Interface::Name_); 56 RemoveInterface(Interface::Name_);
52 } 57 }
53 void RemoveInterface(const std::string& interface_name); 58 void RemoveInterface(const std::string& interface_name);
54 59
55 // Returns true if an InterfaceBinder is registered for |interface_name|. 60 // Returns true if an InterfaceBinder is registered for |interface_name|.
56 bool CanBindInterface(const std::string& interface_name) const; 61 bool CanBindInterface(const std::string& interface_name) const;
(...skipping 18 matching lines...) Expand all
75 80
76 base::WeakPtrFactory<BinderRegistry> weak_factory_; 81 base::WeakPtrFactory<BinderRegistry> weak_factory_;
77 82
78 DISALLOW_COPY_AND_ASSIGN(BinderRegistry); 83 DISALLOW_COPY_AND_ASSIGN(BinderRegistry);
79 }; 84 };
80 85
81 86
82 } // namespace service_manager 87 } // namespace service_manager
83 88
84 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ 89 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_
OLDNEW
« no previous file with comments | « content/test/BUILD.gn ('k') | services/service_manager/public/cpp/binder_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698