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

Side by Side Diff: mojo/shell/application_instance.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/mojo_base.gyp ('k') | mojo/shell/application_instance.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_APPLICATION_INSTANCE_H_ 5 #ifndef MOJO_SHELL_APPLICATION_INSTANCE_H_
6 #define MOJO_SHELL_APPLICATION_INSTANCE_H_ 6 #define MOJO_SHELL_APPLICATION_INSTANCE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
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_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/process/process_handle.h" 15 #include "base/process/process_handle.h"
16 #include "mojo/public/cpp/bindings/binding.h" 16 #include "mojo/public/cpp/bindings/binding.h"
17 #include "mojo/public/cpp/bindings/weak_binding_set.h"
17 #include "mojo/shell/capability_filter.h" 18 #include "mojo/shell/capability_filter.h"
18 #include "mojo/shell/connect_params.h" 19 #include "mojo/shell/connect_params.h"
19 #include "mojo/shell/identity.h" 20 #include "mojo/shell/identity.h"
20 #include "mojo/shell/public/interfaces/application_manager.mojom.h" 21 #include "mojo/shell/public/interfaces/application_manager.mojom.h"
21 #include "mojo/shell/public/interfaces/shell.mojom.h" 22 #include "mojo/shell/public/interfaces/shell.mojom.h"
22 #include "mojo/shell/public/interfaces/shell_client.mojom.h" 23 #include "mojo/shell/public/interfaces/shell_client.mojom.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 namespace mojo { 26 namespace mojo {
26 namespace shell { 27 namespace shell {
27 28
28 class ApplicationManager; 29 class ApplicationManager;
29 class NativeRunner; 30 class NativeRunner;
30 31
31 // Encapsulates a connection to an instance of an application, tracked by the 32 // Encapsulates a connection to an instance of an application, tracked by the
32 // shell's ApplicationManager. 33 // shell's ApplicationManager.
33 class ApplicationInstance : public mojom::Shell, 34 class ApplicationInstance : public mojom::Shell,
35 public mojom::Connector,
34 public mojom::PIDReceiver { 36 public mojom::PIDReceiver {
35 public: 37 public:
36 ApplicationInstance( 38 ApplicationInstance(
37 mojom::ShellClientPtr shell_client, 39 mojom::ShellClientPtr shell_client,
38 ApplicationManager* manager, 40 ApplicationManager* manager,
39 const Identity& identity); 41 const Identity& identity);
40 ~ApplicationInstance() override; 42 ~ApplicationInstance() override;
41 43
42 void InitializeApplication(); 44 void InitializeApplication();
43 45
44 void ConnectToClient(scoped_ptr<ConnectParams> params); 46 void ConnectToClient(scoped_ptr<ConnectParams> params);
45 47
46 // Required before GetProcessId can be called. 48 // Required before GetProcessId can be called.
47 void SetNativeRunner(NativeRunner* native_runner); 49 void SetNativeRunner(NativeRunner* native_runner);
48 50
49 void BindPIDReceiver(InterfaceRequest<mojom::PIDReceiver> pid_receiver); 51 void BindPIDReceiver(InterfaceRequest<mojom::PIDReceiver> pid_receiver);
50 52
51 mojom::ShellClient* shell_client() { return shell_client_.get(); } 53 mojom::ShellClient* shell_client() { return shell_client_.get(); }
52 const Identity& identity() const { return identity_; } 54 const Identity& identity() const { return identity_; }
53 uint32_t id() const { return id_; } 55 uint32_t id() const { return id_; }
54 base::ProcessId pid() const { return pid_; } 56 base::ProcessId pid() const { return pid_; }
55 void set_pid(base::ProcessId pid) { pid_ = pid; } 57 void set_pid(base::ProcessId pid) { pid_ = pid; }
56 58
57 private: 59 private:
58 // Shell implementation: 60 // Shell implementation:
61 void GetConnector(mojom::ConnectorRequest request) override;
62 void QuitApplication() override;
63
64 // Connector implementation:
59 void Connect(const String& app_url, 65 void Connect(const String& app_url,
60 uint32_t user_id, 66 uint32_t user_id,
61 shell::mojom::InterfaceProviderRequest remote_interfaces, 67 shell::mojom::InterfaceProviderRequest remote_interfaces,
62 shell::mojom::InterfaceProviderPtr local_interfaces, 68 shell::mojom::InterfaceProviderPtr local_interfaces,
63 mojom::CapabilityFilterPtr filter, 69 mojom::CapabilityFilterPtr filter,
64 const ConnectCallback& callback) override; 70 const ConnectCallback& callback) override;
65 void QuitApplication() override; 71 void Clone(mojom::ConnectorRequest request) override;
66 72
67 // PIDReceiver implementation: 73 // PIDReceiver implementation:
68 void SetPID(uint32_t pid) override; 74 void SetPID(uint32_t pid) override;
69 75
70 uint32_t GenerateUniqueID() const; 76 uint32_t GenerateUniqueID() const;
71 77
72 void CallAcceptConnection(scoped_ptr<ConnectParams> params); 78 void CallAcceptConnection(scoped_ptr<ConnectParams> params);
73 79
74 void OnConnectionError(); 80 void OnConnectionError();
75 81
76 void OnQuitRequestedResult(bool can_quit); 82 void OnQuitRequestedResult(bool can_quit);
77 83
78 void DestroyRunner(); 84 void DestroyRunner();
79 85
80 ApplicationManager* const manager_; 86 ApplicationManager* const manager_;
81 // An id that identifies this instance. Distinct from pid, as a single process 87 // An id that identifies this instance. Distinct from pid, as a single process
82 // may vend multiple application instances, and this object may exist before a 88 // may vend multiple application instances, and this object may exist before a
83 // process is launched. 89 // process is launched.
84 const uint32_t id_; 90 const uint32_t id_;
85 const Identity identity_; 91 const Identity identity_;
86 const bool allow_any_application_; 92 const bool allow_any_application_;
87 mojom::ShellClientPtr shell_client_; 93 mojom::ShellClientPtr shell_client_;
88 Binding<mojom::Shell> binding_; 94 Binding<mojom::Shell> binding_;
89 Binding<mojom::PIDReceiver> pid_receiver_binding_; 95 Binding<mojom::PIDReceiver> pid_receiver_binding_;
96 WeakBindingSet<mojom::Connector> connectors_;
90 bool queue_requests_; 97 bool queue_requests_;
91 std::vector<ConnectParams*> queued_client_requests_; 98 std::vector<ConnectParams*> queued_client_requests_;
92 NativeRunner* native_runner_; 99 NativeRunner* native_runner_;
93 base::ProcessId pid_; 100 base::ProcessId pid_;
94 101
95 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); 102 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance);
96 }; 103 };
97 104
98 } // namespace shell 105 } // namespace shell
99 } // namespace mojo 106 } // namespace mojo
100 107
101 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ 108 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_
OLDNEW
« no previous file with comments | « mojo/mojo_base.gyp ('k') | mojo/shell/application_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698