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

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

Issue 2131493002: ShellConnection -> ServiceContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@st
Patch Set: . Created 4 years, 5 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 | « services/shell/public/cpp/service.h ('k') | services/shell/public/cpp/service_context_ref.h » ('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_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_SERVICE_CONTEXT_H_
6 #define SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 6 #define SERVICES_SHELL_PUBLIC_CPP_SERVICE_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "mojo/public/cpp/bindings/binding.h" 15 #include "mojo/public/cpp/bindings/binding.h"
16 #include "mojo/public/cpp/system/core.h" 16 #include "mojo/public/cpp/system/core.h"
17 #include "services/shell/public/cpp/service.h" 17 #include "services/shell/public/cpp/service.h"
18 #include "services/shell/public/interfaces/connector.mojom.h" 18 #include "services/shell/public/interfaces/connector.mojom.h"
19 #include "services/shell/public/interfaces/service.mojom.h" 19 #include "services/shell/public/interfaces/service.mojom.h"
20 20
21 namespace shell { 21 namespace shell {
22 22
23 class Connector; 23 class Connector;
24 24
25 // Encapsulates a connection to the Mojo Shell in two parts: 25 // Encapsulates a connection to the Service Manager in two parts:
26 // - a bound InterfacePtr to mojom::Shell, the primary mechanism 26 // - a bound InterfacePtr to mojom::Connector, the primary mechanism
27 // by which the instantiating application interacts with other services 27 // by which the instantiating service connects to other services,
28 // brokered by the Mojo Shell. 28 // brokered by the Service Manager.
29 // - a bound InterfaceRequest of mojom::Service, an interface 29 // - a bound InterfaceRequest of mojom::Service, an interface used by the
30 // used by the Mojo Shell to inform this application of lifecycle events and 30 // Service Manager to inform this service of lifecycle events and
31 // inbound connections brokered by it. 31 // inbound connections brokered by it.
32 // 32 //
33 // This class should be used in two scenarios: 33 // This class should be used in two scenarios:
34 // - During early startup to bind the mojom::ServiceRequest obtained from 34 // - During early startup to bind the mojom::ServiceRequest obtained from
35 // the Mojo Shell, typically in response to either MojoMain() or main(). 35 // the Service Manager, typically in response to either MojoMain() or main().
36 // - In an implementation of mojom::ServiceFactory to bind the 36 // - In an implementation of mojom::ServiceFactory to bind the
37 // mojom::ServiceRequest passed via StartApplication. In this scenario 37 // mojom::ServiceRequest passed via CreateService. In this scenario there can
38 // there can be many instances of this class per process. 38 // be many instances of this class per process.
39 // 39 //
40 // Instances of this class are constructed with an implementation of the Shell 40 // Instances of this class are constructed with an implementation of the Service
41 // Client Lib's Service interface. See documentation in service.h 41 // Manager Client Lib's Service interface. See documentation in service.h
42 // for details. 42 // for details.
43 // 43 //
44 class ShellConnection : public mojom::Service { 44 class ServiceContext : public mojom::Service {
45 public: 45 public:
46 // Creates a new ShellConnection bound to |request|. This connection may be 46 // Creates a new ServiceContext bound to |request|. This connection may be
47 // used immediately to make outgoing connections via connector(). Does not 47 // used immediately to make outgoing connections via connector(). Does not
48 // take ownership of |client|, which must remain valid for the lifetime of 48 // take ownership of |client|, which must remain valid for the lifetime of
49 // ShellConnection. 49 // ServiceContext.
50 ShellConnection(shell::Service* client, 50 ServiceContext(shell::Service* client,
51 mojom::ServiceRequest request); 51 mojom::ServiceRequest request);
52 52
53 ~ShellConnection() override; 53 ~ServiceContext() override;
54 54
55 Connector* connector() { return connector_.get(); } 55 Connector* connector() { return connector_.get(); }
56 const Identity& identity() { return identity_; } 56 const Identity& identity() { return identity_; }
57 57
58 // TODO(rockot): Remove this. http://crbug.com/594852. 58 // TODO(rockot): Remove this. http://crbug.com/594852.
59 void set_initialize_handler(const base::Closure& callback); 59 void set_initialize_handler(const base::Closure& callback);
60 60
61 // TODO(rockot): Remove this once we get rid of app tests. 61 // TODO(rockot): Remove this once we get rid of app tests.
62 void SetAppTestConnectorForTesting(mojom::ConnectorPtr connector); 62 void SetAppTestConnectorForTesting(mojom::ConnectorPtr connector);
63 63
(...skipping 16 matching lines...) Expand all
80 80
81 void OnConnectionError(); 81 void OnConnectionError();
82 82
83 // A callback called when OnStart() is run. 83 // A callback called when OnStart() is run.
84 base::Closure initialize_handler_; 84 base::Closure initialize_handler_;
85 85
86 // We track the lifetime of incoming connection registries as it more 86 // We track the lifetime of incoming connection registries as it more
87 // convenient for the client. 87 // convenient for the client.
88 ScopedVector<Connection> incoming_connections_; 88 ScopedVector<Connection> incoming_connections_;
89 89
90 // A pending Connector request which will eventually be passed to the shell. 90 // A pending Connector request which will eventually be passed to the Service
91 // Manager.
91 mojom::ConnectorRequest pending_connector_request_; 92 mojom::ConnectorRequest pending_connector_request_;
92 93
93 shell::Service* client_; 94 shell::Service* client_;
94 mojo::Binding<mojom::Service> binding_; 95 mojo::Binding<mojom::Service> binding_;
95 std::unique_ptr<Connector> connector_; 96 std::unique_ptr<Connector> connector_;
96 shell::Identity identity_; 97 shell::Identity identity_;
97 bool should_run_connection_lost_closure_ = false; 98 bool should_run_connection_lost_closure_ = false;
98 99
99 base::Closure connection_lost_closure_; 100 base::Closure connection_lost_closure_;
100 101
101 DISALLOW_COPY_AND_ASSIGN(ShellConnection); 102 DISALLOW_COPY_AND_ASSIGN(ServiceContext);
102 }; 103 };
103 104
104 } // namespace shell 105 } // namespace shell
105 106
106 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 107 #endif // SERVICES_SHELL_PUBLIC_CPP_SERVICE_CONTEXT_H_
OLDNEW
« no previous file with comments | « services/shell/public/cpp/service.h ('k') | services/shell/public/cpp/service_context_ref.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698