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

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

Issue 2436763004: More graceful shutdown for ArcSession. (Closed)
Patch Set: Add StopArcInstance 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_service_manager.cc ('k') | components/arc/arc_session.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_SESSION_H_ 5 #ifndef COMPONENTS_ARC_ARC_SESSION_H_
6 #define COMPONENTS_ARC_ARC_SESSION_H_ 6 #define COMPONENTS_ARC_ARC_SESSION_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
11 #include "base/observer_list.h" 12 #include "base/observer_list.h"
12 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/task_runner.h"
14 #include "components/arc/arc_bridge_service.h" 16 #include "components/arc/arc_bridge_service.h"
15 17
16 namespace arc { 18 namespace arc {
17 19
18 // Starts the ARC instance and bootstraps the bridge connection. 20 // Starts the ARC instance and bootstraps the bridge connection.
19 // Clients should implement the Delegate to be notified upon communications 21 // Clients should implement the Delegate to be notified upon communications
20 // being available. 22 // being available.
21 // The instance can be safely removed 1) before Start() is called, or 2) after 23 // The instance can be safely removed 1) before Start() is called, or 2) after
22 // OnStopped() is called. 24 // OnStopped() is called.
23 // The number of instances must be at most one. Otherwise, ARC instances will 25 // The number of instances must be at most one. Otherwise, ARC instances will
(...skipping 10 matching lines...) Expand all
34 36
35 // Called when ARC instance is stopped. This is called exactly once 37 // Called when ARC instance is stopped. This is called exactly once
36 // per instance which is Start()ed. 38 // per instance which is Start()ed.
37 virtual void OnStopped(ArcBridgeService::StopReason reason) = 0; 39 virtual void OnStopped(ArcBridgeService::StopReason reason) = 0;
38 40
39 private: 41 private:
40 DISALLOW_COPY_AND_ASSIGN(Observer); 42 DISALLOW_COPY_AND_ASSIGN(Observer);
41 }; 43 };
42 44
43 // Creates a default instance of ArcSession. 45 // Creates a default instance of ArcSession.
44 static std::unique_ptr<ArcSession> Create(); 46 static std::unique_ptr<ArcSession> Create(
47 const scoped_refptr<base::TaskRunner>& blocking_task_runner);
45 virtual ~ArcSession(); 48 virtual ~ArcSession();
46 49
47 // Starts and bootstraps a connection with the instance. The Observer's 50 // Starts and bootstraps a connection with the instance. The Observer's
48 // OnReady() will be called if the bootstrapping is successful, or 51 // OnReady() will be called if the bootstrapping is successful, or
49 // OnStopped() if it is not. Start() should not be called twice or more. 52 // OnStopped() if it is not. Start() should not be called twice or more.
50 virtual void Start() = 0; 53 virtual void Start() = 0;
51 54
52 // Requests to stop the currently-running instance. 55 // Requests to stop the currently-running instance.
53 // The completion is notified via OnStopped() of the Delegate. 56 // The completion is notified via OnStopped() of the Delegate.
54 virtual void Stop() = 0; 57 virtual void Stop() = 0;
55 58
59 // Called when Chrome is in shutdown state. This is called when the message
60 // loop is already stopped, and the instance will soon be deleted.
61 virtual void OnShutdown() = 0;
62
56 void AddObserver(Observer* observer); 63 void AddObserver(Observer* observer);
57 void RemoveObserver(Observer* observer); 64 void RemoveObserver(Observer* observer);
58 65
59 protected: 66 protected:
60 ArcSession(); 67 ArcSession();
61 68
62 base::ObserverList<Observer> observer_list_; 69 base::ObserverList<Observer> observer_list_;
63 70
64 private: 71 private:
65 DISALLOW_COPY_AND_ASSIGN(ArcSession); 72 DISALLOW_COPY_AND_ASSIGN(ArcSession);
66 }; 73 };
67 74
68 } // namespace arc 75 } // namespace arc
69 76
70 #endif // COMPONENTS_ARC_ARC_SESSION_H_ 77 #endif // COMPONENTS_ARC_ARC_SESSION_H_
OLDNEW
« no previous file with comments | « components/arc/arc_service_manager.cc ('k') | components/arc/arc_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698