| 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> | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|   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_shell_client_factory_id| is the id of the factory 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 factory the id | 
|   38   // is kInvalidContentHandlerID. |   38   // is kInvalidApplicationID. | 
|   39   ApplicationInstance( |   39   ApplicationInstance( | 
|   40       mojom::ShellClientPtr shell_client, |   40       mojom::ShellClientPtr shell_client, | 
|   41       ApplicationManager* manager, |   41       ApplicationManager* manager, | 
|   42       const Identity& identity, |   42       const Identity& identity, | 
|   43       uint32_t requesting_content_handler_id, |   43       uint32_t requesting_shell_client_factory_id, | 
|   44       const mojom::Shell::ConnectToApplicationCallback& connect_callback, |   44       const mojom::Shell::ConnectToApplicationCallback& connect_callback, | 
|   45       const base::Closure& on_application_end, |   45       const base::Closure& on_application_end, | 
|   46       const String& application_name); |   46       const String& application_name); | 
|   47  |   47  | 
|   48   ~ApplicationInstance() override; |   48   ~ApplicationInstance() override; | 
|   49  |   49  | 
|   50   void InitializeApplication(); |   50   void InitializeApplication(); | 
|   51  |   51  | 
|   52   void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); |   52   void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params); | 
|   53  |   53  | 
|   54   // Required before GetProcessId can be called. |   54   // Required before GetProcessId can be called. | 
|   55   void SetNativeRunner(NativeRunner* native_runner); |   55   void SetNativeRunner(NativeRunner* native_runner); | 
|   56  |   56  | 
|   57   void BindPIDReceiver(InterfaceRequest<mojom::PIDReceiver> pid_receiver); |   57   void BindPIDReceiver(InterfaceRequest<mojom::PIDReceiver> pid_receiver); | 
|   58  |   58  | 
|   59   void RunConnectCallback(); |   59   void RunConnectCallback(); | 
|   60  |   60  | 
|   61   mojom::ShellClient* shell_client() { return shell_client_.get(); } |   61   mojom::ShellClient* shell_client() { return shell_client_.get(); } | 
|   62   const Identity& identity() const { return identity_; } |   62   const Identity& identity() const { return identity_; } | 
|   63   uint32_t id() const { return id_; } |   63   uint32_t id() const { return id_; } | 
|   64   base::ProcessId pid() const { return pid_; } |   64   base::ProcessId pid() const { return pid_; } | 
|   65   void set_pid(base::ProcessId pid) { pid_ = pid; } |   65   void set_pid(base::ProcessId pid) { pid_ = pid; } | 
|   66   base::Closure on_application_end() const { return on_application_end_; } |   66   base::Closure on_application_end() const { return on_application_end_; } | 
|   67   void set_requesting_content_handler_id(uint32_t id) { |   67   void set_requesting_shell_client_factory_id(uint32_t id) { | 
|   68     requesting_content_handler_id_ = id; |   68     requesting_shell_client_factory_id_ = id; | 
|   69   } |   69   } | 
|   70   uint32_t requesting_content_handler_id() const { |   70   uint32_t requesting_shell_client_factory_id() const { | 
|   71     return requesting_content_handler_id_; |   71     return requesting_shell_client_factory_id_; | 
|   72   } |   72   } | 
|   73   const String& application_name() const { return application_name_; } |   73   const String& application_name() const { return application_name_; } | 
|   74  |   74  | 
|   75  private: |   75  private: | 
|   76   // Shell implementation: |   76   // Shell implementation: | 
|   77   void ConnectToApplication( |   77   void ConnectToApplication( | 
|   78       URLRequestPtr app_request, |   78       URLRequestPtr app_request, | 
|   79       shell::mojom::InterfaceProviderRequest remote_interfaces, |   79       shell::mojom::InterfaceProviderRequest remote_interfaces, | 
|   80       shell::mojom::InterfaceProviderPtr local_interfaces, |   80       shell::mojom::InterfaceProviderPtr local_interfaces, | 
|   81       mojom::CapabilityFilterPtr filter, |   81       mojom::CapabilityFilterPtr filter, | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   95  |   95  | 
|   96   void DestroyRunner(); |   96   void DestroyRunner(); | 
|   97  |   97  | 
|   98   ApplicationManager* const manager_; |   98   ApplicationManager* const manager_; | 
|   99   // An id that identifies this instance. Distinct from pid, as a single process |   99   // An id that identifies this instance. Distinct from pid, as a single process | 
|  100   // may vend multiple application instances, and this object may exist before a |  100   // may vend multiple application instances, and this object may exist before a | 
|  101   // process is launched. |  101   // process is launched. | 
|  102   const uint32_t id_; |  102   const uint32_t id_; | 
|  103   const Identity identity_; |  103   const Identity identity_; | 
|  104   const bool allow_any_application_; |  104   const bool allow_any_application_; | 
|  105   uint32_t requesting_content_handler_id_; |  105   uint32_t requesting_shell_client_factory_id_; | 
|  106   mojom::Shell::ConnectToApplicationCallback connect_callback_; |  106   mojom::Shell::ConnectToApplicationCallback connect_callback_; | 
|  107   base::Closure on_application_end_; |  107   base::Closure on_application_end_; | 
|  108   mojom::ShellClientPtr shell_client_; |  108   mojom::ShellClientPtr shell_client_; | 
|  109   Binding<mojom::Shell> binding_; |  109   Binding<mojom::Shell> binding_; | 
|  110   Binding<mojom::PIDReceiver> pid_receiver_binding_; |  110   Binding<mojom::PIDReceiver> pid_receiver_binding_; | 
|  111   bool queue_requests_; |  111   bool queue_requests_; | 
|  112   std::vector<ConnectToApplicationParams*> queued_client_requests_; |  112   std::vector<ConnectToApplicationParams*> queued_client_requests_; | 
|  113   NativeRunner* native_runner_; |  113   NativeRunner* native_runner_; | 
|  114   const String application_name_; |  114   const String application_name_; | 
|  115   base::ProcessId pid_; |  115   base::ProcessId pid_; | 
|  116  |  116  | 
|  117   DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); |  117   DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); | 
|  118 }; |  118 }; | 
|  119  |  119  | 
|  120 }  // namespace shell |  120 }  // namespace shell | 
|  121 }  // namespace mojo |  121 }  // namespace mojo | 
|  122  |  122  | 
|  123 #endif  // MOJO_SHELL_APPLICATION_INSTANCE_H_ |  123 #endif  // MOJO_SHELL_APPLICATION_INSTANCE_H_ | 
| OLD | NEW |