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

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: 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/service_context.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 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
(...skipping 24 matching lines...) Expand all
35 // exactly one instance of this class for every logical service instance running 35 // exactly one instance of this class for every logical service instance running
36 // in the system. 36 // in the system.
37 // 37 //
38 // This class is generally used to handle incoming mojom::ServiceRequests from 38 // This class is generally used to handle incoming mojom::ServiceRequests from
39 // the Service Manager. These can either come from ServiceRunner, from the 39 // the Service Manager. These can either come from ServiceRunner, from the
40 // command-line (in the form of a pipe token), from a mojom::ServiceFactory 40 // command-line (in the form of a pipe token), from a mojom::ServiceFactory
41 // call, or from some other embedded service-running facility defined by the 41 // call, or from some other embedded service-running facility defined by the
42 // client. 42 // client.
43 class ServiceContext : public mojom::Service { 43 class ServiceContext : public mojom::Service {
44 public: 44 public:
45 class TestApi {
Ken Rockot(use gerrit already) 2017/05/09 15:29:34 nit: I'm not really a fan of these TestApi subclas
leonhsl(Using Gerrit) 2017/05/09 23:31:53 Acknowledged.
leonhsl(Using Gerrit) 2017/05/10 09:57:11 Done.
46 public:
47 ~TestApi() = default;
48
49 // Overrides the interface binder for |interface_name| of |service|. This is
50 // a process-wide override, means that |binder| can intercept requests only
51 // if |service| runs in the same process with caller of this function.
52 // You can specify |service| as identity of a particular instance of service
53 // "Foo", or just an identity only having the name "Foo" to specify any
54 // instances of service "Foo" in general.
55 static void SetGlobalBinder(
56 const Identity& service,
Ken Rockot(use gerrit already) 2017/05/09 15:29:34 I wonder if we really want a specific identity to
leonhsl(Using Gerrit) 2017/05/09 23:31:53 Yeah I was afraid in future some test cases may wa
blundell 2017/05/10 08:54:39 Let's leave it simple for now and it will be easy
leonhsl(Using Gerrit) 2017/05/10 09:57:11 I see, will update CL soon.
leonhsl(Using Gerrit) 2017/05/11 02:21:47 Done.
57 const std::string& interface_name,
58 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& binder,
Ken Rockot(use gerrit already) 2017/05/09 15:29:34 In keeping with existing binder callbacks today, t
leonhsl(Using Gerrit) 2017/05/09 23:31:53 Acknowledged.
leonhsl(Using Gerrit) 2017/05/10 09:57:11 Done and Thanks!
59 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner =
60 nullptr);
61
62 // Clears all overridden interface binders for |service|.
63 static void ClearGlobalBinders(const Identity& service);
blundell 2017/05/05 12:56:07 nit: Maybe ClearGlobalBindersForService()?
leonhsl(Using Gerrit) 2017/05/09 00:08:54 Acknowledged.
64
65 private:
66 TestApi() = default;
67
68 DISALLOW_COPY_AND_ASSIGN(TestApi);
69 };
70
45 // Creates a new ServiceContext bound to |request|. This connection may be 71 // Creates a new ServiceContext bound to |request|. This connection may be
46 // used immediately to make outgoing connections via connector(). 72 // used immediately to make outgoing connections via connector().
47 // 73 //
48 // This ServiceContext routes all incoming mojom::Service messages and 74 // This ServiceContext routes all incoming mojom::Service messages and
49 // error signals to |service|, which it owns. 75 // error signals to |service|, which it owns.
50 // 76 //
51 // If either |connector| or |connector_request| is non-null both must be 77 // If either |connector| or |connector_request| is non-null both must be
52 // non-null. If both are null, the context will create its own 78 // non-null. If both are null, the context will create its own
53 // Connector and request to pass to the Service Manager on initialization. 79 // Connector and request to pass to the Service Manager on initialization.
54 // 80 //
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 base::Closure quit_closure_; 159 base::Closure quit_closure_;
134 160
135 base::WeakPtrFactory<ServiceContext> weak_factory_; 161 base::WeakPtrFactory<ServiceContext> weak_factory_;
136 162
137 DISALLOW_COPY_AND_ASSIGN(ServiceContext); 163 DISALLOW_COPY_AND_ASSIGN(ServiceContext);
138 }; 164 };
139 165
140 } // namespace service_manager 166 } // namespace service_manager
141 167
142 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_ 168 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/test/BUILD.gn ('k') | services/service_manager/public/cpp/service_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698