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

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

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 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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "mojo/public/cpp/bindings/binding.h" 14 #include "mojo/public/cpp/bindings/binding.h"
15 #include "mojo/public/cpp/system/core.h" 15 #include "mojo/public/cpp/system/core.h"
16 #include "services/service_manager/public/cpp/binder_registry.h"
16 #include "services/service_manager/public/cpp/connector.h" 17 #include "services/service_manager/public/cpp/connector.h"
17 #include "services/service_manager/public/cpp/service.h" 18 #include "services/service_manager/public/cpp/service.h"
18 #include "services/service_manager/public/interfaces/connector.mojom.h" 19 #include "services/service_manager/public/interfaces/connector.mojom.h"
19 #include "services/service_manager/public/interfaces/service.mojom.h" 20 #include "services/service_manager/public/interfaces/service.mojom.h"
20 #include "services/service_manager/public/interfaces/service_control.mojom.h" 21 #include "services/service_manager/public/interfaces/service_control.mojom.h"
21 22
22 namespace service_manager { 23 namespace service_manager {
23 24
24 // Encapsulates a connection to the Service Manager in two parts: 25 // Encapsulates a connection to the Service Manager in two parts:
25 // 26 //
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // receiving Service::OnServiceManagerConnectionLost(). 98 // receiving Service::OnServiceManagerConnectionLost().
98 void DisconnectFromServiceManager(); 99 void DisconnectFromServiceManager();
99 100
100 // Immediately severs the connection to the Service Manager and invokes the 101 // Immediately severs the connection to the Service Manager and invokes the
101 // quit closure (see SetQuitClosure() above) if one has been set. 102 // quit closure (see SetQuitClosure() above) if one has been set.
102 // 103 //
103 // See comments on DisconnectFromServiceManager() regarding abrupt 104 // See comments on DisconnectFromServiceManager() regarding abrupt
104 // disconnection from the Service Manager. 105 // disconnection from the Service Manager.
105 void QuitNow(); 106 void QuitNow();
106 107
108 // Overrides the interface binder for |interface_name| of |service_name|.
109 // This is a process-wide override, meaning that |binder| can intercept
110 // requests against only those |service_name| service instances running in the
111 // same process with caller of this function.
112 static void SetGlobalBinderForTesting(
113 const std::string& service_name,
114 const std::string& interface_name,
115 const BinderRegistry::Binder& binder,
116 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = nullptr);
117
118 // Clears all overridden interface binders for service |service_name| set via
119 // SetGlobalBinderForTesting().
120 static void ClearGlobalBindersForTesting(const std::string& service_name);
121
107 private: 122 private:
108 friend class service_manager::Service; 123 friend class service_manager::Service;
109 124
110 // mojom::Service: 125 // mojom::Service:
111 void OnStart(const Identity& info, const OnStartCallback& callback) override; 126 void OnStart(const Identity& info, const OnStartCallback& callback) override;
112 void OnBindInterface(const BindSourceInfo& source_info, 127 void OnBindInterface(const BindSourceInfo& source_info,
113 const std::string& interface_name, 128 const std::string& interface_name,
114 mojo::ScopedMessagePipeHandle interface_pipe, 129 mojo::ScopedMessagePipeHandle interface_pipe,
115 const OnBindInterfaceCallback& callback) override; 130 const OnBindInterfaceCallback& callback) override;
116 131
(...skipping 16 matching lines...) Expand all
133 base::Closure quit_closure_; 148 base::Closure quit_closure_;
134 149
135 base::WeakPtrFactory<ServiceContext> weak_factory_; 150 base::WeakPtrFactory<ServiceContext> weak_factory_;
136 151
137 DISALLOW_COPY_AND_ASSIGN(ServiceContext); 152 DISALLOW_COPY_AND_ASSIGN(ServiceContext);
138 }; 153 };
139 154
140 } // namespace service_manager 155 } // namespace service_manager
141 156
142 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 157 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698