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

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

Issue 2425753002: Rename ArcBridgeBootstrap to ArcSession. (Closed)
Patch Set: Address comment. Created 4 years, 2 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
« no previous file with comments | « components/arc/arc_bridge_service.h ('k') | components/arc/arc_bridge_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SERVICE_IMPL_H_ 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/files/scoped_file.h" 12 #include "base/files/scoped_file.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "components/arc/arc_bridge_bootstrap.h"
16 #include "components/arc/arc_bridge_service.h" 15 #include "components/arc/arc_bridge_service.h"
16 #include "components/arc/arc_session.h"
17 #include "mojo/public/cpp/bindings/binding.h" 17 #include "mojo/public/cpp/bindings/binding.h"
18 18
19 namespace base { 19 namespace base {
20 class SequencedTaskRunner; 20 class SequencedTaskRunner;
21 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
22 } // namespace base 22 } // namespace base
23 23
24 namespace arc { 24 namespace arc {
25 25
26 // Real IPC based ArcBridgeService that is used in production. 26 // Real IPC based ArcBridgeService that is used in production.
27 class ArcBridgeServiceImpl : public ArcBridgeService, 27 class ArcBridgeServiceImpl : public ArcBridgeService,
28 public ArcBridgeBootstrap::Observer { 28 public ArcSession::Observer {
29 public: 29 public:
30 // This is the factory interface to inject ArcBridgeBootstrap instance 30 // This is the factory interface to inject ArcSession instance
31 // for testing purpose. 31 // for testing purpose.
32 using ArcBridgeBootstrapFactory = 32 using ArcSessionFactory = base::Callback<std::unique_ptr<ArcSession>()>;
33 base::Callback<std::unique_ptr<ArcBridgeBootstrap>()>;
34 33
35 ArcBridgeServiceImpl(); 34 ArcBridgeServiceImpl();
36 ~ArcBridgeServiceImpl() override; 35 ~ArcBridgeServiceImpl() override;
37 36
38 void HandleStartup() override; 37 void HandleStartup() override;
39 38
40 void Shutdown() override; 39 void Shutdown() override;
41 40
42 // Inject a factory to create ArcBridgeBootstrap instance for testing 41 // Inject a factory to create ArcSession instance for testing purpose.
43 // purpose. |factory| must not be null. 42 // |factory| must not be null.
44 void SetArcBridgeBootstrapFactoryForTesting( 43 void SetArcSessionFactoryForTesting(const ArcSessionFactory& factory);
45 const ArcBridgeBootstrapFactory& factory);
46 44
47 // Returns the current bootstrap instance for testing purpose. 45 // Returns the current ArcSession instance for testing purpose.
48 ArcBridgeBootstrap* GetBootstrapForTesting() { return bootstrap_.get(); } 46 ArcSession* GetArcSessionForTesting() { return arc_session_.get(); }
49 47
50 // Normally, reconnecting after connection shutdown happens after a short 48 // Normally, reconnecting after connection shutdown happens after a short
51 // delay. When testing, however, we'd like it to happen immediately to avoid 49 // delay. When testing, however, we'd like it to happen immediately to avoid
52 // adding unnecessary delays. 50 // adding unnecessary delays.
53 void DisableReconnectDelayForTesting(); 51 void DisableReconnectDelayForTesting();
54 52
55 private: 53 private:
56 friend class ArcBridgeTest; 54 friend class ArcBridgeTest;
57 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); 55 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart);
58 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped); 56 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped);
59 57
60 // If all pre-requisites are true (ARC is available, it has been enabled, and 58 // If all pre-requisites are true (ARC is available, it has been enabled, and
61 // the session has started), and ARC is stopped, start ARC. If ARC is running 59 // the session has started), and ARC is stopped, start ARC. If ARC is running
62 // and the pre-requisites stop being true, stop ARC. 60 // and the pre-requisites stop being true, stop ARC.
63 void PrerequisitesChanged(); 61 void PrerequisitesChanged();
64 62
65 // Stops the running instance. 63 // Stops the running instance.
66 void StopInstance(); 64 void StopInstance();
67 65
68 // ArcBridgeBootstrap::Observer: 66 // ArcSession::Observer:
69 void OnReady() override; 67 void OnReady() override;
70 void OnStopped(StopReason reason) override; 68 void OnStopped(StopReason reason) override;
71 69
72 std::unique_ptr<ArcBridgeBootstrap> bootstrap_; 70 std::unique_ptr<ArcSession> arc_session_;
73 71
74 // If the user's session has started. 72 // If the user's session has started.
75 bool session_started_; 73 bool session_started_;
76 74
77 // If the instance had already been started but the connection to it was 75 // If the instance had already been started but the connection to it was
78 // lost. This should make the instance restart. 76 // lost. This should make the instance restart.
79 bool reconnect_ = false; 77 bool reconnect_ = false;
80 78
81 // Delay the reconnection. 79 // Delay the reconnection.
82 bool use_delay_before_reconnecting_ = true; 80 bool use_delay_before_reconnecting_ = true;
83 81
84 // Factory to inject a fake ArcBridgeBootstrap instance for testing. 82 // Factory to inject a fake ArcSession instance for testing.
85 ArcBridgeBootstrapFactory factory_; 83 ArcSessionFactory factory_;
86 84
87 // WeakPtrFactory to use callbacks. 85 // WeakPtrFactory to use callbacks.
88 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; 86 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_;
89 87
90 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); 88 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl);
91 }; 89 };
92 90
93 } // namespace arc 91 } // namespace arc
94 92
95 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ 93 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « components/arc/arc_bridge_service.h ('k') | components/arc/arc_bridge_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698