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

Side by Side Diff: chrome/browser/ui/webui/media_router/query_result_manager.h

Issue 2678123003: Revert of Convert MediaRouter mojom apis to intake url::Origin objects instead of strings (Closed)
Patch Set: Created 3 years, 10 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 CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_
6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <unordered_set> 11 #include <unordered_set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "chrome/browser/media/router/media_routes_observer.h" 17 #include "chrome/browser/media/router/media_routes_observer.h"
18 #include "chrome/browser/media/router/media_sink.h" 18 #include "chrome/browser/media/router/media_sink.h"
19 #include "chrome/browser/media/router/media_source.h" 19 #include "chrome/browser/media/router/media_source.h"
20 #include "chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.h" 20 #include "chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.h"
21 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h" 21 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h"
22 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h" 22 #include "chrome/browser/ui/webui/media_router/media_sink_with_cast_modes.h"
23 23
24 namespace url { 24 class GURL;
25 class Origin;
26 } // namespace url
27 25
28 namespace media_router { 26 namespace media_router {
29 27
30 class MediaRouter; 28 class MediaRouter;
31 class MediaSinksObserver; 29 class MediaSinksObserver;
32 30
33 // The Media Router dialog allows the user to initiate casting using one of 31 // The Media Router dialog allows the user to initiate casting using one of
34 // several actions (each represented by a cast mode). Each cast mode is 32 // several actions (each represented by a cast mode). Each cast mode is
35 // associated with a vector of media sources. This class allows the dialog to 33 // associated with a vector of media sources. This class allows the dialog to
36 // receive lists of MediaSinks compatible with the cast modes available through 34 // receive lists of MediaSinks compatible with the cast modes available through
37 // the dialog. 35 // the dialog.
38 // 36 //
39 // Typical use: 37 // Typical use:
40 // 38 //
41 // url::Origin origin{GURL("https://origin.com")}; 39 // GURL origin("https://origin.com");
42 // QueryResultManager::Observer* observer = ...; 40 // QueryResultManager::Observer* observer = ...;
43 // QueryResultManager result_manager(router); 41 // QueryResultManager result_manager(router);
44 // result_manager.AddObserver(observer); 42 // result_manager.AddObserver(observer);
45 // result_manager.SetSourcesForCastMode(MediaCastMode::DEFAULT, 43 // result_manager.SetSourcesForCastMode(MediaCastMode::DEFAULT,
46 // {MediaSourceForPresentationUrl("http://google.com")}, origin); 44 // {MediaSourceForPresentationUrl("http://google.com")}, origin);
47 // result_manager.SetSourcesForCastMode(MediaCastMode::TAB_MIRROR, 45 // result_manager.SetSourcesForCastMode(MediaCastMode::TAB_MIRROR,
48 // {MediaSourceForTab(123)}, origin); 46 // {MediaSourceForTab(123)}, origin);
49 // ... 47 // ...
50 // [Updates will be received by observer via OnResultsUpdated()] 48 // [Updates will be received by observer via OnResultsUpdated()]
51 // ... 49 // ...
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Results are sent to all observers registered with AddObserver(). 82 // Results are sent to all observers registered with AddObserver().
85 // 83 //
86 // Starts new queries in the Media Router for sources that we have no existing 84 // Starts new queries in the Media Router for sources that we have no existing
87 // queries for, and stops queries for sources no longer associated with any 85 // queries for, and stops queries for sources no longer associated with any
88 // cast mode. 86 // cast mode.
89 // 87 //
90 // If |sources| is empty or contains a source that has already been registered 88 // If |sources| is empty or contains a source that has already been registered
91 // with another cast mode, no new queries are begun. 89 // with another cast mode, no new queries are begun.
92 void SetSourcesForCastMode(MediaCastMode cast_mode, 90 void SetSourcesForCastMode(MediaCastMode cast_mode,
93 const std::vector<MediaSource>& sources, 91 const std::vector<MediaSource>& sources,
94 const url::Origin& origin); 92 const GURL& origin);
95 93
96 // Stops notifying observers for |cast_mode|, and removes it from the set of 94 // Stops notifying observers for |cast_mode|, and removes it from the set of
97 // supported cast modes. 95 // supported cast modes.
98 void RemoveSourcesForCastMode(MediaCastMode cast_mode); 96 void RemoveSourcesForCastMode(MediaCastMode cast_mode);
99 97
100 // Gets the set of cast modes that are being actively queried. 98 // Gets the set of cast modes that are being actively queried.
101 CastModeSet GetSupportedCastModes() const; 99 CastModeSet GetSupportedCastModes() const;
102 100
103 // Gets the highest-priority source for the cast mode that is supported by 101 // Gets the highest-priority source for the cast mode that is supported by
104 // the sink. Returns an empty unique_ptr if there isn't any. 102 // the sink. Returns an empty unique_ptr if there isn't any.
(...skipping 17 matching lines...) Expand all
122 // Stops and destroys the MediaSinksObservers for media sources that 120 // Stops and destroys the MediaSinksObservers for media sources that
123 // |cast_mode| used to support, but isn't in |new_sources|, and disassociates 121 // |cast_mode| used to support, but isn't in |new_sources|, and disassociates
124 // them from sinks. 122 // them from sinks.
125 void RemoveOldSourcesForCastMode(MediaCastMode cast_mode, 123 void RemoveOldSourcesForCastMode(MediaCastMode cast_mode,
126 const std::vector<MediaSource>& new_sources); 124 const std::vector<MediaSource>& new_sources);
127 125
128 // Creates observers and starts queries for each source in |sources| that 126 // Creates observers and starts queries for each source in |sources| that
129 // doesn't already have an associated observer. 127 // doesn't already have an associated observer.
130 void AddObserversForCastMode(MediaCastMode cast_mode, 128 void AddObserversForCastMode(MediaCastMode cast_mode,
131 const std::vector<MediaSource>& sources, 129 const std::vector<MediaSource>& sources,
132 const url::Origin& origin); 130 const GURL& origin);
133 131
134 // Modifies the set of sinks compatible with |cast_mode| and |source| 132 // Modifies the set of sinks compatible with |cast_mode| and |source|
135 // to |new_sinks|. 133 // to |new_sinks|.
136 void SetSinksCompatibleWithSource(MediaCastMode cast_mode, 134 void SetSinksCompatibleWithSource(MediaCastMode cast_mode,
137 const MediaSource& source, 135 const MediaSource& source,
138 const std::vector<MediaSink>& new_sinks); 136 const std::vector<MediaSink>& new_sinks);
139 137
140 // Returns the highest-priority source for |cast_mode| contained in 138 // Returns the highest-priority source for |cast_mode| contained in
141 // |sources_for_sink|. Returns an empty unique_ptr if none exists. 139 // |sources_for_sink|. Returns an empty unique_ptr if none exists.
142 std::unique_ptr<MediaSource> GetHighestPrioritySourceForCastModeAndSink( 140 std::unique_ptr<MediaSource> GetHighestPrioritySourceForCastModeAndSink(
(...skipping 29 matching lines...) Expand all
172 170
173 // Not owned by this object. 171 // Not owned by this object.
174 MediaRouter* const router_; 172 MediaRouter* const router_;
175 173
176 DISALLOW_COPY_AND_ASSIGN(QueryResultManager); 174 DISALLOW_COPY_AND_ASSIGN(QueryResultManager);
177 }; 175 };
178 176
179 } // namespace media_router 177 } // namespace media_router
180 178
181 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_ 179 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_QUERY_RESULT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698