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

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

Issue 2567083002: Migrate ArcBridgeService::Observer and ArcSession::Observer. (Closed)
Patch Set: rebase Created 4 years 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.cc ('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 "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/task_runner.h" 16 #include "base/task_runner.h"
17 #include "components/arc/arc_bridge_service.h" 17 #include "components/arc/arc_bridge_service.h"
18 #include "components/arc/arc_session.h" 18 #include "components/arc/arc_session_observer.h"
19 #include "mojo/public/cpp/bindings/binding.h" 19 #include "mojo/public/cpp/bindings/binding.h"
20 20
21 namespace arc { 21 namespace arc {
22 22
23 class ArcSession;
24
23 // Real IPC based ArcBridgeService that is used in production. 25 // Real IPC based ArcBridgeService that is used in production.
24 class ArcBridgeServiceImpl : public ArcBridgeService, 26 class ArcBridgeServiceImpl : public ArcBridgeService,
25 public ArcSession::Observer { 27 public ArcSessionObserver {
26 public: 28 public:
27 // This is the factory interface to inject ArcSession instance 29 // This is the factory interface to inject ArcSession instance
28 // for testing purpose. 30 // for testing purpose.
29 using ArcSessionFactory = base::Callback<std::unique_ptr<ArcSession>()>; 31 using ArcSessionFactory = base::Callback<std::unique_ptr<ArcSession>()>;
30 32
31 explicit ArcBridgeServiceImpl( 33 explicit ArcBridgeServiceImpl(
32 const scoped_refptr<base::TaskRunner>& blocking_task_runner); 34 const scoped_refptr<base::TaskRunner>& blocking_task_runner);
33 ~ArcBridgeServiceImpl() override; 35 ~ArcBridgeServiceImpl() override;
34 36
35 // ArcBridgeService overrides: 37 // ArcBridgeService overrides:
(...skipping 19 matching lines...) Expand all
55 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped); 57 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, OnBridgeStopped);
56 58
57 // If all pre-requisites are true (ARC is available, it has been enabled, and 59 // If all pre-requisites are true (ARC is available, it has been enabled, and
58 // the session has started), and ARC is stopped, start ARC. If ARC is running 60 // the session has started), and ARC is stopped, start ARC. If ARC is running
59 // and the pre-requisites stop being true, stop ARC. 61 // and the pre-requisites stop being true, stop ARC.
60 void PrerequisitesChanged(); 62 void PrerequisitesChanged();
61 63
62 // Stops the running instance. 64 // Stops the running instance.
63 void StopInstance(); 65 void StopInstance();
64 66
65 // ArcSession::Observer: 67 // ArcSessionObserver:
66 void OnReady() override; 68 void OnSessionReady() override;
67 void OnStopped(StopReason reason) override; 69 void OnSessionStopped(StopReason reason) override;
68 70
69 std::unique_ptr<ArcSession> arc_session_; 71 std::unique_ptr<ArcSession> arc_session_;
70 72
71 // If the user's session has started. 73 // If the user's session has started.
72 bool session_started_; 74 bool session_started_;
73 75
74 // If the instance had already been started but the connection to it was 76 // If the instance had already been started but the connection to it was
75 // lost. This should make the instance restart. 77 // lost. This should make the instance restart.
76 bool reconnect_ = false; 78 bool reconnect_ = false;
77 79
78 // Delay the reconnection. 80 // Delay the reconnection.
79 bool use_delay_before_reconnecting_ = true; 81 bool use_delay_before_reconnecting_ = true;
80 82
81 // Factory to inject a fake ArcSession instance for testing. 83 // Factory to inject a fake ArcSession instance for testing.
82 ArcSessionFactory factory_; 84 ArcSessionFactory factory_;
83 85
84 // WeakPtrFactory to use callbacks. 86 // WeakPtrFactory to use callbacks.
85 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; 87 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_;
86 88
87 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); 89 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl);
88 }; 90 };
89 91
90 } // namespace arc 92 } // namespace arc
91 93
92 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ 94 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « components/arc/arc_bridge_service.cc ('k') | components/arc/arc_bridge_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698