Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: components/arc/arc_bridge_bootstrap.h

Issue 2133653002: arc: Notify ARC instance failures via callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "components/arc/arc_bridge_service.h"
13 #include "components/arc/common/arc_bridge.mojom.h" 14 #include "components/arc/common/arc_bridge.mojom.h"
14 15
15 namespace arc { 16 namespace arc {
16 17
17 // Starts the ARC instance and bootstraps the bridge connection. 18 // Starts the ARC instance and bootstraps the bridge connection.
18 // Clients should implement the Delegate to be notified upon communications 19 // Clients should implement the Delegate to be notified upon communications
19 // being available. 20 // being available.
20 class ArcBridgeBootstrap { 21 class ArcBridgeBootstrap {
21 public: 22 public:
23 using StopReason = ArcBridgeService::StopReason;
24
22 class Delegate { 25 class Delegate {
23 public: 26 public:
27 // Called when the connection with ARC instance has been established.
24 virtual void OnConnectionEstablished( 28 virtual void OnConnectionEstablished(
25 mojom::ArcBridgeInstancePtr instance_ptr) = 0; 29 mojom::ArcBridgeInstancePtr instance_ptr) = 0;
26 virtual void OnStopped() = 0; 30
31 // Called when ARC instance is stopped.
32 virtual void OnStopped(StopReason reason) = 0;
27 }; 33 };
28 34
29 // Creates a default instance of ArcBridgeBootstrap. 35 // Creates a default instance of ArcBridgeBootstrap.
30 static std::unique_ptr<ArcBridgeBootstrap> Create(); 36 static std::unique_ptr<ArcBridgeBootstrap> Create();
31 virtual ~ArcBridgeBootstrap() = default; 37 virtual ~ArcBridgeBootstrap() = default;
32 38
33 // This must be called before calling Start() or Stop(). |delegate| is owned 39 // This must be called before calling Start() or Stop(). |delegate| is owned
34 // by the caller and must outlive this instance. 40 // by the caller and must outlive this instance.
35 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 41 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
36 42
(...skipping 11 matching lines...) Expand all
48 // Owned by the caller. 54 // Owned by the caller.
49 Delegate* delegate_ = nullptr; 55 Delegate* delegate_ = nullptr;
50 56
51 private: 57 private:
52 DISALLOW_COPY_AND_ASSIGN(ArcBridgeBootstrap); 58 DISALLOW_COPY_AND_ASSIGN(ArcBridgeBootstrap);
53 }; 59 };
54 60
55 } // namespace arc 61 } // namespace arc
56 62
57 #endif // COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ 63 #endif // COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698