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

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

Issue 2720303002: Do nothing on OnSessionStopped if ARC is being restarted. (Closed)
Patch Set: Get rid of ArcSessionObserver Created 3 years, 9 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
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/memory/ref_counted.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/task_runner.h" 15 #include "base/task_runner.h"
16 #include "components/arc/arc_bridge_service.h" 16 #include "components/arc/arc_bridge_service.h"
17 #include "components/arc/arc_stop_reason.h"
17 18
18 namespace arc { 19 namespace arc {
19 20
20 class ArcSessionObserver;
Yusuke Sato 2017/03/01 15:51:01 'git grep ArcSessionObserver' please, just to make
hidehiko 2017/03/01 17:28:03 Yes, I had done, and no ArcSessionObserver should
21
22 // Starts the ARC instance and bootstraps the bridge connection. 21 // Starts the ARC instance and bootstraps the bridge connection.
23 // Clients should implement the Delegate to be notified upon communications 22 // Clients should implement the Delegate to be notified upon communications
24 // being available. 23 // being available.
25 // The instance can be safely removed 1) before Start() is called, or 2) after 24 // The instance can be safely removed 1) before Start() is called, or 2) after
26 // OnStopped() is called. 25 // OnStopped() is called.
27 // The number of instances must be at most one. Otherwise, ARC instances will 26 // The number of instances must be at most one. Otherwise, ARC instances will
28 // conflict. 27 // conflict.
29 class ArcSession { 28 class ArcSession {
30 public: 29 public:
30 class Observer {
Yusuke Sato 2017/03/01 15:51:01 nit: comment on who should use it?
hidehiko 2017/03/01 17:28:02 I added a brief comment, thought I wonder if it is
31 public:
32 // Called when the connection with ARC instance has been established.
33 virtual void OnSessionReady() = 0;
34
35 // Called when ARC instance is stopped. This is called exactly once
36 // per instance which is Start()ed.
37 virtual void OnSessionStopped(ArcStopReason reason) = 0;
38
39 protected:
40 // Do not directly create/destroy the instance via the interface.
41 Observer() = default;
42 ~Observer() = default;
43 };
44
31 // Creates a default instance of ArcSession. 45 // Creates a default instance of ArcSession.
32 static std::unique_ptr<ArcSession> Create( 46 static std::unique_ptr<ArcSession> Create(
33 ArcBridgeService* arc_bridge_service, 47 ArcBridgeService* arc_bridge_service,
34 const scoped_refptr<base::TaskRunner>& blocking_task_runner); 48 const scoped_refptr<base::TaskRunner>& blocking_task_runner);
35 virtual ~ArcSession(); 49 virtual ~ArcSession();
36 50
37 // Starts and bootstraps a connection with the instance. The Observer's 51 // Starts and bootstraps a connection with the instance. The Observer's
38 // OnReady() will be called if the bootstrapping is successful, or 52 // OnReady() will be called if the bootstrapping is successful, or
39 // OnStopped() if it is not. Start() should not be called twice or more. 53 // OnStopped() if it is not. Start() should not be called twice or more.
40 virtual void Start() = 0; 54 virtual void Start() = 0;
41 55
42 // Requests to stop the currently-running instance. 56 // Requests to stop the currently-running instance.
43 // The completion is notified via OnStopped() of the Delegate. 57 // The completion is notified via OnStopped() of the Delegate.
44 virtual void Stop() = 0; 58 virtual void Stop() = 0;
45 59
46 // Called when Chrome is in shutdown state. This is called when the message 60 // Called when Chrome is in shutdown state. This is called when the message
47 // loop is already stopped, and the instance will soon be deleted. 61 // loop is already stopped, and the instance will soon be deleted.
48 virtual void OnShutdown() = 0; 62 virtual void OnShutdown() = 0;
49 63
50 void AddObserver(ArcSessionObserver* observer); 64 void AddObserver(Observer* observer);
51 void RemoveObserver(ArcSessionObserver* observer); 65 void RemoveObserver(Observer* observer);
52 66
53 protected: 67 protected:
54 ArcSession(); 68 ArcSession();
55 69
56 base::ObserverList<ArcSessionObserver> observer_list_; 70 base::ObserverList<Observer> observer_list_;
57 71
58 private: 72 private:
59 DISALLOW_COPY_AND_ASSIGN(ArcSession); 73 DISALLOW_COPY_AND_ASSIGN(ArcSession);
60 }; 74 };
61 75
62 } // namespace arc 76 } // namespace arc
63 77
64 #endif // COMPONENTS_ARC_ARC_SESSION_H_ 78 #endif // COMPONENTS_ARC_ARC_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698