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

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

Issue 2436763004: More graceful shutdown for ArcSession. (Closed)
Patch Set: Add StopArcInstance Created 4 years, 1 month 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 "base/memory/ref_counted.h"
16 #include "base/task_runner.h"
15 #include "components/arc/arc_bridge_service.h" 17 #include "components/arc/arc_bridge_service.h"
16 #include "components/arc/arc_session.h" 18 #include "components/arc/arc_session.h"
17 #include "mojo/public/cpp/bindings/binding.h" 19 #include "mojo/public/cpp/bindings/binding.h"
18 20
19 namespace base { 21 namespace base {
20 class SequencedTaskRunner; 22 class SequencedTaskRunner;
21 class SingleThreadTaskRunner; 23 class SingleThreadTaskRunner;
22 } // namespace base 24 } // namespace base
23 25
24 namespace arc { 26 namespace arc {
25 27
26 // Real IPC based ArcBridgeService that is used in production. 28 // Real IPC based ArcBridgeService that is used in production.
27 class ArcBridgeServiceImpl : public ArcBridgeService, 29 class ArcBridgeServiceImpl : public ArcBridgeService,
28 public ArcSession::Observer { 30 public ArcSession::Observer {
29 public: 31 public:
30 // This is the factory interface to inject ArcSession instance 32 // This is the factory interface to inject ArcSession instance
31 // for testing purpose. 33 // for testing purpose.
32 using ArcSessionFactory = base::Callback<std::unique_ptr<ArcSession>()>; 34 using ArcSessionFactory = base::Callback<std::unique_ptr<ArcSession>()>;
33 35
34 ArcBridgeServiceImpl(); 36 explicit ArcBridgeServiceImpl(
37 const scoped_refptr<base::TaskRunner>& blocking_task_runner);
35 ~ArcBridgeServiceImpl() override; 38 ~ArcBridgeServiceImpl() override;
36 39
37 void HandleStartup() override; 40 // ArcBridgeService overrides:
38 41 void RequestStart() override;
39 void Shutdown() override; 42 void RequestStop() override;
43 void OnShutdown() override;
40 44
41 // Inject a factory to create ArcSession instance for testing purpose. 45 // Inject a factory to create ArcSession instance for testing purpose.
42 // |factory| must not be null. 46 // |factory| must not be null.
43 void SetArcSessionFactoryForTesting(const ArcSessionFactory& factory); 47 void SetArcSessionFactoryForTesting(const ArcSessionFactory& factory);
44 48
45 // Returns the current ArcSession instance for testing purpose. 49 // Returns the current ArcSession instance for testing purpose.
46 ArcSession* GetArcSessionForTesting() { return arc_session_.get(); } 50 ArcSession* GetArcSessionForTesting() { return arc_session_.get(); }
47 51
48 // Normally, reconnecting after connection shutdown happens after a short 52 // Normally, reconnecting after connection shutdown happens after a short
49 // delay. When testing, however, we'd like it to happen immediately to avoid 53 // delay. When testing, however, we'd like it to happen immediately to avoid
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 88
85 // WeakPtrFactory to use callbacks. 89 // WeakPtrFactory to use callbacks.
86 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; 90 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_;
87 91
88 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); 92 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl);
89 }; 93 };
90 94
91 } // namespace arc 95 } // namespace arc
92 96
93 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ 97 #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