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 <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 // Encapsulates a connection to an instance of an application, tracked by the | 25 // Encapsulates a connection to an instance of an application, tracked by the |
26 // shell's ApplicationManager. | 26 // shell's ApplicationManager. |
27 class ApplicationInstance : public Shell { | 27 class ApplicationInstance : public Shell { |
28 public: | 28 public: |
29 // |requesting_content_handler_id| is the id of the content handler that | 29 // |requesting_content_handler_id| is the id of the content handler that |
30 // loaded this app. If the app was not loaded by a content handler the id | 30 // loaded this app. If the app was not loaded by a content handler the id |
31 // is kInvalidContentHandlerID. | 31 // is kInvalidContentHandlerID. |
32 ApplicationInstance(ApplicationPtr application, | 32 ApplicationInstance(ApplicationPtr application, |
33 ApplicationManager* manager, | 33 ApplicationManager* manager, |
34 const Identity& originator_identity, | 34 const Identity& identity, |
35 const Identity& resolved_identity, | |
36 const CapabilityFilter& filter, | |
37 uint32_t requesting_content_handler_id, | 35 uint32_t requesting_content_handler_id, |
38 const base::Closure& on_application_end); | 36 const base::Closure& on_application_end); |
39 | 37 |
40 ~ApplicationInstance() override; | 38 ~ApplicationInstance() override; |
41 | 39 |
42 void InitializeApplication(); | 40 void InitializeApplication(); |
43 | 41 |
44 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); | 42 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); |
45 | 43 |
46 Application* application() { return application_.get(); } | 44 Application* application() { return application_.get(); } |
47 const Identity& identity() const { return identity_; } | 45 const Identity& identity() const { return identity_; } |
48 const CapabilityFilter& filter() const { return filter_; } | |
49 base::Closure on_application_end() const { return on_application_end_; } | 46 base::Closure on_application_end() const { return on_application_end_; } |
50 void set_requesting_content_handler_id(uint32_t id) { | 47 void set_requesting_content_handler_id(uint32_t id) { |
51 requesting_content_handler_id_ = id; | 48 requesting_content_handler_id_ = id; |
52 } | 49 } |
53 uint32_t requesting_content_handler_id() const { | 50 uint32_t requesting_content_handler_id() const { |
54 return requesting_content_handler_id_; | 51 return requesting_content_handler_id_; |
55 } | 52 } |
56 | 53 |
57 private: | 54 private: |
58 // Shell implementation: | 55 // Shell implementation: |
59 void ConnectToApplication( | 56 void ConnectToApplication( |
60 URLRequestPtr app_request, | 57 URLRequestPtr app_request, |
61 InterfaceRequest<ServiceProvider> services, | 58 InterfaceRequest<ServiceProvider> services, |
62 ServiceProviderPtr exposed_services, | 59 ServiceProviderPtr exposed_services, |
63 CapabilityFilterPtr filter, | 60 CapabilityFilterPtr filter, |
64 const ConnectToApplicationCallback& callback) override; | 61 const ConnectToApplicationCallback& callback) override; |
65 void QuitApplication() override; | 62 void QuitApplication() override; |
66 | 63 |
67 void CallAcceptConnection(scoped_ptr<ConnectToApplicationParams> params); | 64 void CallAcceptConnection(scoped_ptr<ConnectToApplicationParams> params); |
68 | 65 |
69 void OnConnectionError(); | 66 void OnConnectionError(); |
70 | 67 |
71 void OnQuitRequestedResult(bool can_quit); | 68 void OnQuitRequestedResult(bool can_quit); |
72 | 69 |
73 ApplicationManager* const manager_; | 70 ApplicationManager* const manager_; |
74 const Identity originator_identity_; | |
75 const Identity identity_; | 71 const Identity identity_; |
76 const CapabilityFilter filter_; | |
77 const bool allow_any_application_; | 72 const bool allow_any_application_; |
78 uint32_t requesting_content_handler_id_; | 73 uint32_t requesting_content_handler_id_; |
79 base::Closure on_application_end_; | 74 base::Closure on_application_end_; |
80 ApplicationPtr application_; | 75 ApplicationPtr application_; |
81 Binding<Shell> binding_; | 76 Binding<Shell> binding_; |
82 bool queue_requests_; | 77 bool queue_requests_; |
83 std::vector<ConnectToApplicationParams*> queued_client_requests_; | 78 std::vector<ConnectToApplicationParams*> queued_client_requests_; |
84 | 79 |
85 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); | 80 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); |
86 }; | 81 }; |
87 | 82 |
88 } // namespace shell | 83 } // namespace shell |
89 } // namespace mojo | 84 } // namespace mojo |
90 | 85 |
91 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ | 86 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ |
OLD | NEW |