| 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 COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ | 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ |
| 6 #define COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ | 6 #define COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 public: | 21 public: |
| 22 class Delegate { | 22 class Delegate { |
| 23 public: | 23 public: |
| 24 virtual void OnConnectionEstablished( | 24 virtual void OnConnectionEstablished( |
| 25 mojom::ArcBridgeInstancePtr instance_ptr) = 0; | 25 mojom::ArcBridgeInstancePtr instance_ptr) = 0; |
| 26 virtual void OnStopped() = 0; | 26 virtual void OnStopped() = 0; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // Creates a default instance of ArcBridgeBootstrap. | 29 // Creates a default instance of ArcBridgeBootstrap. |
| 30 static std::unique_ptr<ArcBridgeBootstrap> Create(); | 30 static std::unique_ptr<ArcBridgeBootstrap> Create(); |
| 31 virtual ~ArcBridgeBootstrap(); | 31 virtual ~ArcBridgeBootstrap() = default; |
| 32 | 32 |
| 33 // This must be called before calling Start() or Stop(). |delegate| is owned | 33 // This must be called before calling Start() or Stop(). |delegate| is owned |
| 34 // by the caller and must outlive this instance. | 34 // by the caller and must outlive this instance. |
| 35 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 35 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 36 | 36 |
| 37 // Starts and bootstraps a connection with the instance. The Delegate's | 37 // Starts and bootstraps a connection with the instance. The Delegate's |
| 38 // OnConnectionEstablished() will be called if the bootstrapping is | 38 // OnConnectionEstablished() will be called if the bootstrapping is |
| 39 // successful, or OnStopped() if it is not. | 39 // successful, or OnStopped() if it is not. |
| 40 virtual void Start() = 0; | 40 virtual void Start() = 0; |
| 41 | 41 |
| 42 // Stops the currently-running instance. | 42 // Stops the currently-running instance. |
| 43 virtual void Stop() = 0; | 43 virtual void Stop() = 0; |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 ArcBridgeBootstrap(); | 46 ArcBridgeBootstrap() = default; |
| 47 | 47 |
| 48 // Owned by the caller. | 48 // Owned by the caller. |
| 49 Delegate* delegate_ = nullptr; | 49 Delegate* delegate_ = nullptr; |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(ArcBridgeBootstrap); | 52 DISALLOW_COPY_AND_ASSIGN(ArcBridgeBootstrap); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 } // namespace arc | 55 } // namespace arc |
| 56 | 56 |
| 57 #endif // COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ | 57 #endif // COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ |
| OLD | NEW |