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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace arc { | 23 namespace arc { |
24 | 24 |
25 // Real IPC based ArcBridgeService that is used in production. | 25 // Real IPC based ArcBridgeService that is used in production. |
26 class ArcBridgeServiceImpl : public ArcBridgeService, | 26 class ArcBridgeServiceImpl : public ArcBridgeService, |
27 public ArcBridgeBootstrap::Delegate { | 27 public ArcBridgeBootstrap::Delegate { |
28 public: | 28 public: |
29 explicit ArcBridgeServiceImpl(scoped_ptr<ArcBridgeBootstrap> bootstrap); | 29 explicit ArcBridgeServiceImpl(scoped_ptr<ArcBridgeBootstrap> bootstrap); |
30 ~ArcBridgeServiceImpl() override; | 30 ~ArcBridgeServiceImpl() override; |
31 | 31 |
32 void DetectAvailability() override; | 32 void SetDetectedAvailability(bool available) override; |
33 | 33 |
34 void HandleStartup() override; | 34 void HandleStartup() override; |
35 | 35 |
36 void Shutdown() override; | 36 void Shutdown() override; |
37 | 37 |
38 private: | 38 private: |
39 friend class ArcBridgeTest; | 39 friend class ArcBridgeTest; |
40 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); | 40 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); |
41 | 41 |
42 // If all pre-requisites are true (ARC is available, it has been enabled, and | 42 // If all pre-requisites are true (ARC is available, it has been enabled, and |
43 // the session has started), and ARC is stopped, start ARC. If ARC is running | 43 // the session has started), and ARC is stopped, start ARC. If ARC is running |
44 // and the pre-requisites stop being true, stop ARC. | 44 // and the pre-requisites stop being true, stop ARC. |
45 void PrerequisitesChanged(); | 45 void PrerequisitesChanged(); |
46 | 46 |
47 // Stops the running instance. | 47 // Stops the running instance. |
48 void StopInstance(); | 48 void StopInstance(); |
49 | 49 |
50 // ArcBridgeBootstrap::Delegate: | 50 // ArcBridgeBootstrap::Delegate: |
51 void OnConnectionEstablished(ArcBridgeInstancePtr instance) override; | 51 void OnConnectionEstablished(ArcBridgeInstancePtr instance) override; |
52 void OnStopped() override; | 52 void OnStopped() override; |
53 | 53 |
54 // DBus callbacks. | |
55 void OnArcAvailable(bool available); | |
56 | |
57 // Called when the bridge channel is closed. This typically only happens when | 54 // Called when the bridge channel is closed. This typically only happens when |
58 // the ARC instance crashes. This is not called during shutdown. | 55 // the ARC instance crashes. This is not called during shutdown. |
59 void OnChannelClosed(); | 56 void OnChannelClosed(); |
60 | 57 |
61 scoped_ptr<ArcBridgeBootstrap> bootstrap_; | 58 scoped_ptr<ArcBridgeBootstrap> bootstrap_; |
62 | 59 |
63 // Mojo endpoints. | 60 // Mojo endpoints. |
64 mojo::Binding<ArcBridgeHost> binding_; | 61 mojo::Binding<ArcBridgeHost> binding_; |
65 ArcBridgeInstancePtr instance_ptr_; | 62 ArcBridgeInstancePtr instance_ptr_; |
66 | 63 |
67 // If the user's session has started. | 64 // If the user's session has started. |
68 bool session_started_; | 65 bool session_started_; |
69 | 66 |
70 // If the instance had already been started but the connection to it was | 67 // If the instance had already been started but the connection to it was |
71 // lost. This should make the instance restart. | 68 // lost. This should make the instance restart. |
72 bool reconnect_ = false; | 69 bool reconnect_ = false; |
73 | 70 |
74 // WeakPtrFactory to use callbacks. | 71 // WeakPtrFactory to use callbacks. |
75 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; | 72 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; |
76 | 73 |
77 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); | 74 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); |
78 }; | 75 }; |
79 | 76 |
80 } // namespace arc | 77 } // namespace arc |
81 | 78 |
82 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | 79 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ |
OLD | NEW |