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

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

Issue 1728083002: Extract a Connector interface from Shell that can be cloned & passed to other threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@12uid
Patch Set: . Created 4 years, 10 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 | « mojo/shell/public/cpp/shell.h ('k') | mojo/shell/public/interfaces/shell.mojom » ('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 MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_
6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.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/bindings/callback.h" 15 #include "mojo/public/cpp/bindings/callback.h"
16 #include "mojo/public/cpp/system/core.h" 16 #include "mojo/public/cpp/system/core.h"
17 #include "mojo/shell/public/cpp/shell.h" 17 #include "mojo/shell/public/cpp/shell.h"
18 #include "mojo/shell/public/cpp/shell_client.h" 18 #include "mojo/shell/public/cpp/shell_client.h"
19 #include "mojo/shell/public/interfaces/shell.mojom.h" 19 #include "mojo/shell/public/interfaces/shell.mojom.h"
20 #include "mojo/shell/public/interfaces/shell_client.mojom.h" 20 #include "mojo/shell/public/interfaces/shell_client.mojom.h"
21 21
22 namespace mojo { 22 namespace mojo {
23 23
24 class AppRefCountImpl; 24 class AppRefCountImpl;
25 class Connector;
25 26
26 // Encapsulates a connection to the Mojo Shell in two parts: 27 // Encapsulates a connection to the Mojo Shell in two parts:
27 // - a bound InterfacePtr to mojo::shell::mojom::Shell, the primary mechanism 28 // - a bound InterfacePtr to mojo::shell::mojom::Shell, the primary mechanism
28 // by which the instantiating application interacts with other services 29 // by which the instantiating application interacts with other services
29 // brokered by the Mojo Shell. 30 // brokered by the Mojo Shell.
30 // - a bound InterfaceRequest of mojo::shell::mojom::ShellClient, an interface 31 // - a bound InterfaceRequest of mojo::shell::mojom::ShellClient, an interface
31 // used by the Mojo Shell to inform this application of lifecycle events and 32 // used by the Mojo Shell to inform this application of lifecycle events and
32 // inbound connections brokered by it. 33 // inbound connections brokered by it.
33 // 34 //
34 // This class should be used in two scenarios: 35 // This class should be used in two scenarios:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 // Block the calling thread until the Initialize() method is called by the 79 // Block the calling thread until the Initialize() method is called by the
79 // shell. 80 // shell.
80 void WaitForInitialize(); 81 void WaitForInitialize();
81 82
82 private: 83 private:
83 friend AppRefCountImpl; 84 friend AppRefCountImpl;
84 85
85 // Shell: 86 // Shell:
86 scoped_ptr<Connection> Connect(const std::string& url) override; 87 scoped_ptr<Connection> Connect(const std::string& url) override;
87 scoped_ptr<Connection> Connect(ConnectParams* params) override; 88 scoped_ptr<Connection> Connect(Connector::ConnectParams* params) override;
89 scoped_ptr<Connector> CloneConnector() const override;
88 void Quit() override; 90 void Quit() override;
89 scoped_ptr<AppRefCount> CreateAppRefCount() override; 91 scoped_ptr<AppRefCount> CreateAppRefCount() override;
90 92
91 // shell::mojom::ShellClient: 93 // shell::mojom::ShellClient:
92 void Initialize(shell::mojom::ShellPtr shell, 94 void Initialize(shell::mojom::ShellPtr shell,
93 const mojo::String& url, 95 const mojo::String& url,
94 uint32_t id, 96 uint32_t id,
95 uint32_t user_id) override; 97 uint32_t user_id) override;
96 void AcceptConnection( 98 void AcceptConnection(
97 const String& requestor_url, 99 const String& requestor_url,
(...skipping 20 matching lines...) Expand all
118 // Called from AppRefCountImpl. 120 // Called from AppRefCountImpl.
119 void AddRef(); 121 void AddRef();
120 void Release(); 122 void Release();
121 123
122 // We track the lifetime of incoming connection registries as it more 124 // We track the lifetime of incoming connection registries as it more
123 // convenient for the client. 125 // convenient for the client.
124 ScopedVector<Connection> incoming_connections_; 126 ScopedVector<Connection> incoming_connections_;
125 mojo::ShellClient* client_; 127 mojo::ShellClient* client_;
126 Binding<shell::mojom::ShellClient> binding_; 128 Binding<shell::mojom::ShellClient> binding_;
127 shell::mojom::ShellPtr shell_; 129 shell::mojom::ShellPtr shell_;
130 scoped_ptr<Connector> connector_;
128 Closure termination_closure_; 131 Closure termination_closure_;
129 bool quit_requested_; 132 bool quit_requested_;
130 int ref_count_; 133 int ref_count_;
131 base::WeakPtrFactory<ShellConnection> weak_factory_; 134 base::WeakPtrFactory<ShellConnection> weak_factory_;
132 135
133 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellConnection); 136 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellConnection);
134 }; 137 };
135 138
136 } // namespace mojo 139 } // namespace mojo
137 140
138 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 141 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/shell.h ('k') | mojo/shell/public/interfaces/shell.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698