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_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" | 15 #include "components/arc/arc_bridge_bootstrap.h" |
16 #include "components/arc/arc_bridge_service.h" | 16 #include "components/arc/arc_bridge_service.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::Delegate { | 28 public ArcBridgeBootstrap::Observer { |
29 public: | 29 public: |
30 // This is the factory interface to inject ArcBridgeBootstrap instance | 30 // This is the factory interface to inject ArcBridgeBootstrap instance |
31 // for testing purpose. | 31 // for testing purpose. |
32 using ArcBridgeBootstrapFactory = | 32 using ArcBridgeBootstrapFactory = |
33 base::Callback<std::unique_ptr<ArcBridgeBootstrap>()>; | 33 base::Callback<std::unique_ptr<ArcBridgeBootstrap>()>; |
34 | 34 |
35 ArcBridgeServiceImpl(); | 35 ArcBridgeServiceImpl(); |
36 ~ArcBridgeServiceImpl() override; | 36 ~ArcBridgeServiceImpl() override; |
37 | 37 |
38 void HandleStartup() override; | 38 void HandleStartup() override; |
(...skipping 19 matching lines...) Expand all Loading... |
58 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped); | 58 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped); |
59 | 59 |
60 // If all pre-requisites are true (ARC is available, it has been enabled, and | 60 // 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 | 61 // the session has started), and ARC is stopped, start ARC. If ARC is running |
62 // and the pre-requisites stop being true, stop ARC. | 62 // and the pre-requisites stop being true, stop ARC. |
63 void PrerequisitesChanged(); | 63 void PrerequisitesChanged(); |
64 | 64 |
65 // Stops the running instance. | 65 // Stops the running instance. |
66 void StopInstance(); | 66 void StopInstance(); |
67 | 67 |
68 // ArcBridgeBootstrap::Delegate: | 68 // ArcBridgeBootstrap::Observer: |
69 void OnConnectionEstablished(mojom::ArcBridgeInstancePtr instance) override; | 69 void OnReady() override; |
70 void OnStopped(StopReason reason) override; | 70 void OnStopped(StopReason reason) override; |
71 | 71 |
72 std::unique_ptr<ArcBridgeBootstrap> bootstrap_; | 72 std::unique_ptr<ArcBridgeBootstrap> bootstrap_; |
73 | 73 |
74 // If the user's session has started. | 74 // If the user's session has started. |
75 bool session_started_; | 75 bool session_started_; |
76 | 76 |
77 // Mojo endpoint. | |
78 // TODO(hidehiko): Move this to ArcBridgeBootstrap. | |
79 std::unique_ptr<mojom::ArcBridgeHost> arc_bridge_host_; | |
80 | |
81 // If the instance had already been started but the connection to it was | 77 // If the instance had already been started but the connection to it was |
82 // lost. This should make the instance restart. | 78 // lost. This should make the instance restart. |
83 bool reconnect_ = false; | 79 bool reconnect_ = false; |
84 | 80 |
85 // Delay the reconnection. | 81 // Delay the reconnection. |
86 bool use_delay_before_reconnecting_ = true; | 82 bool use_delay_before_reconnecting_ = true; |
87 | 83 |
88 // Factory to inject a fake ArcBridgeBootstrap instance for testing. | 84 // Factory to inject a fake ArcBridgeBootstrap instance for testing. |
89 ArcBridgeBootstrapFactory factory_; | 85 ArcBridgeBootstrapFactory factory_; |
90 | 86 |
91 // WeakPtrFactory to use callbacks. | 87 // WeakPtrFactory to use callbacks. |
92 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; | 88 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; |
93 | 89 |
94 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); | 90 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); |
95 }; | 91 }; |
96 | 92 |
97 } // namespace arc | 93 } // namespace arc |
98 | 94 |
99 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | 95 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ |
OLD | NEW |