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

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

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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_SHELL_CONNECTION_H_
6 #define SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 6 #define SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_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"
15 #include "mojo/public/cpp/bindings/binding.h" 14 #include "mojo/public/cpp/bindings/binding.h"
16 #include "mojo/public/cpp/system/core.h" 15 #include "mojo/public/cpp/system/core.h"
16 #include "services/shell/public/cpp/connector.h"
17 #include "services/shell/public/cpp/shell_client.h" 17 #include "services/shell/public/cpp/shell_client.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/shell_client.mojom.h" 19 #include "services/shell/public/interfaces/shell_client.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 Mojo Shell in two parts:
26 // - a bound InterfacePtr to mojom::Shell, the primary mechanism 26 // - a bound InterfacePtr to mojom::Shell, the primary mechanism
(...skipping 12 matching lines...) Expand all
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 Shell
41 // Client Lib's ShellClient interface. See documentation in shell_client.h 41 // Client Lib's ShellClient interface. See documentation in shell_client.h
42 // for details. 42 // for details.
43 // 43 //
44 class ShellConnection : public mojom::ShellClient { 44 class ShellConnection : public mojom::ShellClient {
45 public: 45 public:
46 // Creates a new ShellConnection bound to |request|. This connection may be 46 // Creates a new ShellConnection 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 // ShellConnection. If either |connector| or |connector_request| is non-null
50 // both must be non-null. If both are null, the connection will create its own
51 // Connector and request to pass to the shell on initialization.
50 ShellConnection(shell::ShellClient* client, 52 ShellConnection(shell::ShellClient* client,
51 mojom::ShellClientRequest request); 53 mojom::ShellClientRequest request,
54 std::unique_ptr<Connector> connector = nullptr,
55 mojom::ConnectorRequest connector_request = nullptr);
52 56
53 ~ShellConnection() override; 57 ~ShellConnection() override;
54 58
55 Connector* connector() { return connector_.get(); } 59 Connector* connector() { return connector_.get(); }
56 const Identity& identity() { return identity_; } 60 const Identity& identity() { return identity_; }
57 61
58 // TODO(rockot): Remove this. http://crbug.com/594852. 62 // TODO(rockot): Remove this. http://crbug.com/594852.
59 void set_initialize_handler(const base::Closure& callback); 63 void set_initialize_handler(const base::Closure& callback);
60 64
61 // TODO(rockot): Remove this once we get rid of app tests. 65 // TODO(rockot): Remove this once we get rid of app tests.
(...skipping 16 matching lines...) Expand all
78 mojom::CapabilityRequestPtr allowed_capabilities, 82 mojom::CapabilityRequestPtr allowed_capabilities,
79 const mojo::String& name) override; 83 const mojo::String& name) override;
80 84
81 void OnConnectionError(); 85 void OnConnectionError();
82 86
83 // A callback called when Initialize() is run. 87 // A callback called when Initialize() is run.
84 base::Closure initialize_handler_; 88 base::Closure initialize_handler_;
85 89
86 // We track the lifetime of incoming connection registries as it more 90 // We track the lifetime of incoming connection registries as it more
87 // convenient for the client. 91 // convenient for the client.
88 ScopedVector<Connection> incoming_connections_; 92 std::vector<std::unique_ptr<Connection>> incoming_connections_;
89 93
90 // A pending Connector request which will eventually be passed to the shell. 94 // A pending Connector request which will eventually be passed to the shell.
91 mojom::ConnectorRequest pending_connector_request_; 95 mojom::ConnectorRequest pending_connector_request_;
92 96
93 shell::ShellClient* client_; 97 shell::ShellClient* client_;
94 mojo::Binding<mojom::ShellClient> binding_; 98 mojo::Binding<mojom::ShellClient> binding_;
95 std::unique_ptr<Connector> connector_; 99 std::unique_ptr<Connector> connector_;
96 shell::Identity identity_; 100 shell::Identity identity_;
97 bool should_run_connection_lost_closure_ = false; 101 bool should_run_connection_lost_closure_ = false;
98 102
99 base::Closure connection_lost_closure_; 103 base::Closure connection_lost_closure_;
100 104
101 DISALLOW_COPY_AND_ASSIGN(ShellConnection); 105 DISALLOW_COPY_AND_ASSIGN(ShellConnection);
102 }; 106 };
103 107
104 } // namespace shell 108 } // namespace shell
105 109
106 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 110 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_
OLDNEW
« content/gpu/gpu_child_thread.cc ('K') | « services/shell/public/cpp/lib/shell_connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698