| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ | 6 #define CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/common/mojo_application_info.h" | 12 #include "content/public/common/mojo_application_info.h" |
| 13 #include "services/shell/public/cpp/identity.h" | 13 #include "services/shell/public/cpp/identity.h" |
| 14 #include "services/shell/public/interfaces/service.mojom.h" | 14 #include "services/shell/public/interfaces/service.mojom.h" |
| 15 | 15 |
| 16 namespace shell { | 16 namespace shell { |
| 17 class Connection; | 17 class Connection; |
| 18 class Connector; | 18 class Connector; |
| 19 class ShellConnection; | 19 class ServiceContext; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 // Encapsulates a connection to a //services/shell. | 24 // Encapsulates a connection to a //services/shell. |
| 25 // Access a global instance on the thread the ShellConnection was bound by | 25 // Access a global instance on the thread the ServiceContext was bound by |
| 26 // calling Holder::Get(). | 26 // calling Holder::Get(). |
| 27 // Clients can add shell::Service implementations whose exposed interfaces | 27 // Clients can add shell::Service implementations whose exposed interfaces |
| 28 // will be exposed to inbound connections to this object's Service. | 28 // will be exposed to inbound connections to this object's Service. |
| 29 // Alternatively clients can define named services that will be constructed when | 29 // Alternatively clients can define named services that will be constructed when |
| 30 // requests for those service names are received. | 30 // requests for those service names are received. |
| 31 // Clients must call any of the registration methods when receiving | 31 // Clients must call any of the registration methods when receiving |
| 32 // ContentBrowserClient::RegisterInProcessMojoApplications(). | 32 // ContentBrowserClient::RegisterInProcessMojoApplications(). |
| 33 class CONTENT_EXPORT MojoShellConnection { | 33 class CONTENT_EXPORT MojoShellConnection { |
| 34 public: | 34 public: |
| 35 using ServiceRequestHandler = | 35 using ServiceRequestHandler = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 52 virtual ~MojoShellConnection(); | 52 virtual ~MojoShellConnection(); |
| 53 | 53 |
| 54 // Sets the factory used to create the MojoShellConnection. This must be | 54 // Sets the factory used to create the MojoShellConnection. This must be |
| 55 // called before the MojoShellConnection has been created. | 55 // called before the MojoShellConnection has been created. |
| 56 static void SetFactoryForTest(Factory* factory); | 56 static void SetFactoryForTest(Factory* factory); |
| 57 | 57 |
| 58 // Creates a MojoShellConnection from |request|. | 58 // Creates a MojoShellConnection from |request|. |
| 59 static std::unique_ptr<MojoShellConnection> Create( | 59 static std::unique_ptr<MojoShellConnection> Create( |
| 60 shell::mojom::ServiceRequest request); | 60 shell::mojom::ServiceRequest request); |
| 61 | 61 |
| 62 // Returns the bound shell::ShellConnection object. | 62 // Returns the bound shell::ServiceContext object. |
| 63 // TODO(rockot): remove. | 63 // TODO(rockot): remove. |
| 64 virtual shell::ShellConnection* GetShellConnection() = 0; | 64 virtual shell::ServiceContext* GetShellConnection() = 0; |
| 65 | 65 |
| 66 // Returns the shell::Connector received via this connection's Service | 66 // Returns the shell::Connector received via this connection's Service |
| 67 // implementation. Use this to initiate connections as this object's Identity. | 67 // implementation. Use this to initiate connections as this object's Identity. |
| 68 virtual shell::Connector* GetConnector() = 0; | 68 virtual shell::Connector* GetConnector() = 0; |
| 69 | 69 |
| 70 // Returns this connection's identity with the shell. Connections initiated | 70 // Returns this connection's identity with the shell. Connections initiated |
| 71 // via the shell::Connector returned by GetConnector() will use this. | 71 // via the shell::Connector returned by GetConnector() will use this. |
| 72 virtual const shell::Identity& GetIdentity() const = 0; | 72 virtual const shell::Identity& GetIdentity() const = 0; |
| 73 | 73 |
| 74 // Sets a closure that is called when the connection is lost. Note that | 74 // Sets a closure that is called when the connection is lost. Note that |
| (...skipping 21 matching lines...) Expand all Loading... |
| 96 // For in-process services, it is preferable to use |AddEmbeddedService()| as | 96 // For in-process services, it is preferable to use |AddEmbeddedService()| as |
| 97 // defined above. | 97 // defined above. |
| 98 virtual void AddServiceRequestHandler( | 98 virtual void AddServiceRequestHandler( |
| 99 const std::string& name, | 99 const std::string& name, |
| 100 const ServiceRequestHandler& handler) = 0; | 100 const ServiceRequestHandler& handler) = 0; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace content | 103 } // namespace content |
| 104 | 104 |
| 105 #endif // CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ | 105 #endif // CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ |
| OLD | NEW |