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

Side by Side Diff: ash/cast_config_delegate.h

Issue 1567103005: Replace base::CallbackList with base::ObserverList in CastConfigDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Add DISALLOW_ASSIGN to Observer Created 4 years, 11 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 | « no previous file | ash/system/cast/tray_cast.h » ('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 ASH_CAST_CONFIG_DELEGATE_H_ 5 #ifndef ASH_CAST_CONFIG_DELEGATE_H_
6 #define ASH_CAST_CONFIG_DELEGATE_H_ 6 #define ASH_CAST_CONFIG_DELEGATE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "base/callback.h"
13 #include "base/callback_list.h"
14 #include "base/macros.h" 12 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
17 #include "url/gurl.h" 15 #include "url/gurl.h"
18 16
19 namespace ash { 17 namespace ash {
20 18
21 // This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|, 19 // This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|,
22 // to access the cast extension. 20 // to access the cast extension.
23 class CastConfigDelegate { 21 class CastConfigDelegate {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }; 62 };
65 63
66 struct ASH_EXPORT ReceiverAndActivity { 64 struct ASH_EXPORT ReceiverAndActivity {
67 ReceiverAndActivity(); 65 ReceiverAndActivity();
68 ~ReceiverAndActivity(); 66 ~ReceiverAndActivity();
69 67
70 Receiver receiver; 68 Receiver receiver;
71 Activity activity; 69 Activity activity;
72 }; 70 };
73 71
74 // The key is the receiver id.
75 using ReceiversAndActivities = std::vector<ReceiverAndActivity>; 72 using ReceiversAndActivities = std::vector<ReceiverAndActivity>;
76 using ReceiversAndActivitesCallback = 73
77 base::Callback<void(const ReceiversAndActivities&)>; 74 class ASH_EXPORT Observer {
78 using DeviceUpdateSubscription = scoped_ptr< 75 public:
79 base::CallbackList<void(const ReceiversAndActivities&)>::Subscription>; 76 // Invoked whenever there is new receiver or activity information available.
77 virtual void OnDevicesUpdated(const ReceiversAndActivities& devices) = 0;
78
79 protected:
80 virtual ~Observer() {}
81
82 private:
83 DISALLOW_ASSIGN(Observer);
achuithb 2016/01/13 22:05:44 Isn't DISALLOW_COPY_AND_ASSIGN better here?
jdufault 2016/01/13 22:12:14 That causes a compilation error, with it you need
achuithb 2016/01/13 22:19:27 Acknowledged.
84 };
80 85
81 virtual ~CastConfigDelegate() {} 86 virtual ~CastConfigDelegate() {}
82 87
83 // Returns true if cast extension is installed. 88 // Returns true if cast extension is installed.
84 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is 89 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is
85 // gone. See crbug.com/551132. 90 // gone. See crbug.com/551132.
86 virtual bool HasCastExtension() const = 0; 91 virtual bool HasCastExtension() const = 0;
87 92
88 // Adds a listener that will get invoked whenever the receivers or their
89 // associated activites have changed.
90 virtual DeviceUpdateSubscription RegisterDeviceUpdateObserver(
91 const ReceiversAndActivitesCallback& callback) = 0;
92
93 // Request fresh data from the backend. When the data is available, all 93 // Request fresh data from the backend. When the data is available, all
94 // registered observers will get called. 94 // registered observers will get called.
95 virtual void RequestDeviceRefresh() = 0; 95 virtual void RequestDeviceRefresh() = 0;
96 96
97 // Cast to a receiver specified by |receiver_id|. 97 // Cast to a receiver specified by |receiver_id|.
98 virtual void CastToReceiver(const std::string& receiver_id) = 0; 98 virtual void CastToReceiver(const std::string& receiver_id) = 0;
99 99
100 // Stop an ongoing cast (this should be a user initiated stop). |activity_id| 100 // Stop an ongoing cast (this should be a user initiated stop). |activity_id|
101 // is the identifier of the activity/route that should be stopped. 101 // is the identifier of the activity/route that should be stopped.
102 virtual void StopCasting(const std::string& activity_id) = 0; 102 virtual void StopCasting(const std::string& activity_id) = 0;
103 103
104 // Does the device have a settings page? 104 // Does the device have a settings page?
105 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is 105 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is
106 // gone. See crbug.com/551132. 106 // gone. See crbug.com/551132.
107 virtual bool HasOptions() const = 0; 107 virtual bool HasOptions() const = 0;
108 108
109 // Opens Options page for cast. 109 // Opens Options page for cast.
110 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is 110 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is
111 // gone. See crbug.com/551132. 111 // gone. See crbug.com/551132.
112 virtual void LaunchCastOptions() = 0; 112 virtual void LaunchCastOptions() = 0;
113 113
114 // Add or remove an observer.
115 virtual void AddObserver(Observer* observer) = 0;
116 virtual void RemoveObserver(Observer* observer) = 0;
117
114 private: 118 private:
115 DISALLOW_ASSIGN(CastConfigDelegate); 119 DISALLOW_ASSIGN(CastConfigDelegate);
116 }; 120 };
117 121
118 } // namespace ash 122 } // namespace ash
119 123
120 #endif // ASH_CAST_CONFIG_DELEGATE_H_ 124 #endif // ASH_CAST_CONFIG_DELEGATE_H_
OLDNEW
« no previous file with comments | « no previous file | ash/system/cast/tray_cast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698