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

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 AbortReason = ArcBridgeService::AbortReason;
24
22 class Delegate { 25 class Delegate {
23 public: 26 public:
27 // Called when a connection with ARC instance has been established.
Luis Héctor Chávez 2016/07/08 18:01:02 nit: when the connection
Shuhei Takahashi 2016/07/11 08:25:19 Done.
24 virtual void OnConnectionEstablished( 28 virtual void OnConnectionEstablished(
25 mojom::ArcBridgeInstancePtr instance_ptr) = 0; 29 mojom::ArcBridgeInstancePtr instance_ptr) = 0;
30
31 // Called when ARC instance is being aborted due to errors.
32 // This can happen if it has failed to boot, or it has crashed after boot.
33 // After this callback is invoked, the ARC instance will be stopped, so
34 // you do not need to call ArcBridgeBootstrap::Stop() in the callback.
35 // Note: This callback can be called multiple times before OnStopped() if
36 // we encounter multiple errors during the process.
37 virtual void OnAborting(AbortReason reason) = 0;
38
39 // Called when ARC instance has stopped.
40 // When the ARC instance is being aborted due to errors, OnAborting() is
41 // called first, then OnStopped() is called once the instance is stopped.
26 virtual void OnStopped() = 0; 42 virtual void OnStopped() = 0;
Luis Héctor Chávez 2016/07/08 18:01:02 Do you have an example of an instance where OnAbor
Shuhei Takahashi 2016/07/11 08:25:19 It is possible ArcBridgeBootstrap encounters multi
27 }; 43 };
28 44
29 // Creates a default instance of ArcBridgeBootstrap. 45 // Creates a default instance of ArcBridgeBootstrap.
30 static std::unique_ptr<ArcBridgeBootstrap> Create(); 46 static std::unique_ptr<ArcBridgeBootstrap> Create();
31 virtual ~ArcBridgeBootstrap() = default; 47 virtual ~ArcBridgeBootstrap() = default;
32 48
33 // This must be called before calling Start() or Stop(). |delegate| is owned 49 // This must be called before calling Start() or Stop(). |delegate| is owned
34 // by the caller and must outlive this instance. 50 // by the caller and must outlive this instance.
35 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 51 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
36 52
(...skipping 11 matching lines...) Expand all
48 // Owned by the caller. 64 // Owned by the caller.
49 Delegate* delegate_ = nullptr; 65 Delegate* delegate_ = nullptr;
50 66
51 private: 67 private:
52 DISALLOW_COPY_AND_ASSIGN(ArcBridgeBootstrap); 68 DISALLOW_COPY_AND_ASSIGN(ArcBridgeBootstrap);
53 }; 69 };
54 70
55 } // namespace arc 71 } // namespace arc
56 72
57 #endif // COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_ 73 #endif // COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/arc_bridge_bootstrap.cc » ('j') | components/arc/arc_bridge_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698