OLD | NEW |
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/shell/capability_filter.h" | 17 #include "mojo/shell/capability_filter.h" |
18 #include "mojo/shell/connect_to_application_params.h" | 18 #include "mojo/shell/connect_to_application_params.h" |
19 #include "mojo/shell/identity.h" | 19 #include "mojo/shell/identity.h" |
20 #include "mojo/shell/public/interfaces/application.mojom.h" | |
21 #include "mojo/shell/public/interfaces/application_manager.mojom.h" | 20 #include "mojo/shell/public/interfaces/application_manager.mojom.h" |
22 #include "mojo/shell/public/interfaces/shell.mojom.h" | 21 #include "mojo/shell/public/interfaces/shell.mojom.h" |
| 22 #include "mojo/shell/public/interfaces/shell_client.mojom.h" |
23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
24 | 24 |
25 namespace mojo { | 25 namespace mojo { |
26 namespace shell { | 26 namespace shell { |
27 | 27 |
28 class ApplicationManager; | 28 class ApplicationManager; |
29 class NativeRunner; | 29 class NativeRunner; |
30 | 30 |
31 // Encapsulates a connection to an instance of an application, tracked by the | 31 // Encapsulates a connection to an instance of an application, tracked by the |
32 // shell's ApplicationManager. | 32 // shell's ApplicationManager. |
33 class ApplicationInstance : public mojom::Shell, | 33 class ApplicationInstance : public mojom::Shell, |
34 public mojom::PIDReceiver { | 34 public mojom::PIDReceiver { |
35 public: | 35 public: |
36 // |requesting_content_handler_id| is the id of the content handler that | 36 // |requesting_content_handler_id| is the id of the content handler that |
37 // loaded this app. If the app was not loaded by a content handler the id | 37 // loaded this app. If the app was not loaded by a content handler the id |
38 // is kInvalidContentHandlerID. | 38 // is kInvalidContentHandlerID. |
39 ApplicationInstance(mojom::ApplicationPtr application, | 39 ApplicationInstance(mojom::ShellClientPtr shell_client, |
40 ApplicationManager* manager, | 40 ApplicationManager* manager, |
41 const Identity& identity, | 41 const Identity& identity, |
42 uint32_t requesting_content_handler_id, | 42 uint32_t requesting_content_handler_id, |
43 const base::Closure& on_application_end); | 43 const base::Closure& on_application_end); |
44 | 44 |
45 ~ApplicationInstance() override; | 45 ~ApplicationInstance() override; |
46 | 46 |
47 void InitializeApplication(); | 47 void InitializeApplication(); |
48 | 48 |
49 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); | 49 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); |
50 | 50 |
51 // Required before GetProcessId can be called. | 51 // Required before GetProcessId can be called. |
52 void SetNativeRunner(NativeRunner* native_runner); | 52 void SetNativeRunner(NativeRunner* native_runner); |
53 | 53 |
54 void BindPIDReceiver(InterfaceRequest<mojom::PIDReceiver> pid_receiver); | 54 void BindPIDReceiver(InterfaceRequest<mojom::PIDReceiver> pid_receiver); |
55 | 55 |
56 mojom::Application* application() { return application_.get(); } | 56 mojom::ShellClient* shell_client() { return shell_client_.get(); } |
57 const Identity& identity() const { return identity_; } | 57 const Identity& identity() const { return identity_; } |
58 uint32_t id() const { return id_; } | 58 uint32_t id() const { return id_; } |
59 base::ProcessId pid() const { return pid_; } | 59 base::ProcessId pid() const { return pid_; } |
60 void set_pid(base::ProcessId pid) { pid_ = pid; } | 60 void set_pid(base::ProcessId pid) { pid_ = pid; } |
61 base::Closure on_application_end() const { return on_application_end_; } | 61 base::Closure on_application_end() const { return on_application_end_; } |
62 void set_requesting_content_handler_id(uint32_t id) { | 62 void set_requesting_content_handler_id(uint32_t id) { |
63 requesting_content_handler_id_ = id; | 63 requesting_content_handler_id_ = id; |
64 } | 64 } |
65 uint32_t requesting_content_handler_id() const { | 65 uint32_t requesting_content_handler_id() const { |
66 return requesting_content_handler_id_; | 66 return requesting_content_handler_id_; |
(...skipping 24 matching lines...) Expand all Loading... |
91 | 91 |
92 ApplicationManager* const manager_; | 92 ApplicationManager* const manager_; |
93 // An id that identifies this instance. Distinct from pid, as a single process | 93 // An id that identifies this instance. Distinct from pid, as a single process |
94 // may vend multiple application instances, and this object may exist before a | 94 // may vend multiple application instances, and this object may exist before a |
95 // process is launched. | 95 // process is launched. |
96 const uint32_t id_; | 96 const uint32_t id_; |
97 const Identity identity_; | 97 const Identity identity_; |
98 const bool allow_any_application_; | 98 const bool allow_any_application_; |
99 uint32_t requesting_content_handler_id_; | 99 uint32_t requesting_content_handler_id_; |
100 base::Closure on_application_end_; | 100 base::Closure on_application_end_; |
101 mojom::ApplicationPtr application_; | 101 mojom::ShellClientPtr shell_client_; |
102 Binding<mojom::Shell> binding_; | 102 Binding<mojom::Shell> binding_; |
103 Binding<mojom::PIDReceiver> pid_receiver_binding_; | 103 Binding<mojom::PIDReceiver> pid_receiver_binding_; |
104 bool queue_requests_; | 104 bool queue_requests_; |
105 std::vector<ConnectToApplicationParams*> queued_client_requests_; | 105 std::vector<ConnectToApplicationParams*> queued_client_requests_; |
106 NativeRunner* native_runner_; | 106 NativeRunner* native_runner_; |
107 base::ProcessId pid_; | 107 base::ProcessId pid_; |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); | 109 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); |
110 }; | 110 }; |
111 | 111 |
112 } // namespace shell | 112 } // namespace shell |
113 } // namespace mojo | 113 } // namespace mojo |
114 | 114 |
115 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ | 115 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ |
OLD | NEW |