| 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& identity, | 34 const Identity& originator_identity, |
| 35 const Identity& resolved_identity, |
| 36 const CapabilityFilter& filter, |
| 35 uint32_t requesting_content_handler_id, | 37 uint32_t requesting_content_handler_id, |
| 36 const base::Closure& on_application_end); | 38 const base::Closure& on_application_end); |
| 37 | 39 |
| 38 ~ApplicationInstance() override; | 40 ~ApplicationInstance() override; |
| 39 | 41 |
| 40 void InitializeApplication(); | 42 void InitializeApplication(); |
| 41 | 43 |
| 42 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); | 44 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); |
| 43 | 45 |
| 44 Application* application() { return application_.get(); } | 46 Application* application() { return application_.get(); } |
| 45 const Identity& identity() const { return identity_; } | 47 const Identity& identity() const { return identity_; } |
| 48 const CapabilityFilter& filter() const { return filter_; } |
| 46 base::Closure on_application_end() const { return on_application_end_; } | 49 base::Closure on_application_end() const { return on_application_end_; } |
| 47 void set_requesting_content_handler_id(uint32_t id) { | 50 void set_requesting_content_handler_id(uint32_t id) { |
| 48 requesting_content_handler_id_ = id; | 51 requesting_content_handler_id_ = id; |
| 49 } | 52 } |
| 50 uint32_t requesting_content_handler_id() const { | 53 uint32_t requesting_content_handler_id() const { |
| 51 return requesting_content_handler_id_; | 54 return requesting_content_handler_id_; |
| 52 } | 55 } |
| 53 | 56 |
| 54 private: | 57 private: |
| 55 // Shell implementation: | 58 // Shell implementation: |
| 56 void ConnectToApplication( | 59 void ConnectToApplication( |
| 57 URLRequestPtr app_request, | 60 URLRequestPtr app_request, |
| 58 InterfaceRequest<ServiceProvider> services, | 61 InterfaceRequest<ServiceProvider> services, |
| 59 ServiceProviderPtr exposed_services, | 62 ServiceProviderPtr exposed_services, |
| 60 CapabilityFilterPtr filter, | 63 CapabilityFilterPtr filter, |
| 61 const ConnectToApplicationCallback& callback) override; | 64 const ConnectToApplicationCallback& callback) override; |
| 62 void QuitApplication() override; | 65 void QuitApplication() override; |
| 63 | 66 |
| 64 void CallAcceptConnection(scoped_ptr<ConnectToApplicationParams> params); | 67 void CallAcceptConnection(scoped_ptr<ConnectToApplicationParams> params); |
| 65 | 68 |
| 66 void OnConnectionError(); | 69 void OnConnectionError(); |
| 67 | 70 |
| 68 void OnQuitRequestedResult(bool can_quit); | 71 void OnQuitRequestedResult(bool can_quit); |
| 69 | 72 |
| 70 ApplicationManager* const manager_; | 73 ApplicationManager* const manager_; |
| 74 const Identity originator_identity_; |
| 71 const Identity identity_; | 75 const Identity identity_; |
| 76 const CapabilityFilter filter_; |
| 72 const bool allow_any_application_; | 77 const bool allow_any_application_; |
| 73 uint32_t requesting_content_handler_id_; | 78 uint32_t requesting_content_handler_id_; |
| 74 base::Closure on_application_end_; | 79 base::Closure on_application_end_; |
| 75 ApplicationPtr application_; | 80 ApplicationPtr application_; |
| 76 Binding<Shell> binding_; | 81 Binding<Shell> binding_; |
| 77 bool queue_requests_; | 82 bool queue_requests_; |
| 78 std::vector<ConnectToApplicationParams*> queued_client_requests_; | 83 std::vector<ConnectToApplicationParams*> queued_client_requests_; |
| 79 | 84 |
| 80 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); | 85 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); |
| 81 }; | 86 }; |
| 82 | 87 |
| 83 } // namespace shell | 88 } // namespace shell |
| 84 } // namespace mojo | 89 } // namespace mojo |
| 85 | 90 |
| 86 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ | 91 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ |
| OLD | NEW |