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

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

Powered by Google App Engine
This is Rietveld 408576698