| OLD | NEW |
| 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_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <unordered_map> | 15 #include <unordered_map> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/containers/hash_tables.h" | 18 #include "base/containers/hash_tables.h" |
| 19 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 23 #include "base/optional.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 25 #include "chrome/browser/media/router/issue.h" | 26 #include "chrome/browser/media/router/issue.h" |
| 26 #include "chrome/browser/media/router/issue_manager.h" | 27 #include "chrome/browser/media/router/issue_manager.h" |
| 27 #include "chrome/browser/media/router/media_router_base.h" | 28 #include "chrome/browser/media/router/media_router_base.h" |
| 28 #include "chrome/browser/media/router/media_routes_observer.h" | 29 #include "chrome/browser/media/router/media_routes_observer.h" |
| 29 #include "chrome/browser/media/router/mojo/media_router.mojom.h" | 30 #include "chrome/browser/media/router/mojo/media_router.mojom.h" |
| 30 #include "chrome/browser/media/router/route_request_result.h" | 31 #include "chrome/browser/media/router/route_request_result.h" |
| 31 #include "mojo/public/cpp/bindings/binding.h" | 32 #include "mojo/public/cpp/bindings/binding.h" |
| 32 | 33 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // Represents a query to the MRPM for media sinks and holds observers for the | 164 // Represents a query to the MRPM for media sinks and holds observers for the |
| 164 // query. | 165 // query. |
| 165 struct MediaSinksQuery { | 166 struct MediaSinksQuery { |
| 166 public: | 167 public: |
| 167 MediaSinksQuery(); | 168 MediaSinksQuery(); |
| 168 ~MediaSinksQuery(); | 169 ~MediaSinksQuery(); |
| 169 | 170 |
| 170 // True if the query has been sent to the MRPM. | 171 // True if the query has been sent to the MRPM. |
| 171 bool is_active = false; | 172 bool is_active = false; |
| 172 | 173 |
| 173 // True if cached result is available. | 174 // Cached list of sinks and origins for the query. |
| 174 bool has_cached_result = false; | 175 base::Optional<std::vector<MediaSink>> cached_sink_list; |
| 176 std::vector<url::Origin> origins; |
| 175 | 177 |
| 176 // Cached list of sinks for the query, if |has_cached_result| is true. | |
| 177 // Empty otherwise. | |
| 178 std::vector<MediaSink> cached_sink_list; | |
| 179 std::vector<url::Origin> origins; | |
| 180 base::ObserverList<MediaSinksObserver> observers; | 178 base::ObserverList<MediaSinksObserver> observers; |
| 181 | 179 |
| 182 private: | 180 private: |
| 183 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); | 181 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); |
| 184 }; | 182 }; |
| 185 | 183 |
| 186 struct MediaRoutesQuery { | 184 struct MediaRoutesQuery { |
| 187 public: | 185 public: |
| 188 MediaRoutesQuery(); | 186 MediaRoutesQuery(); |
| 189 ~MediaRoutesQuery(); | 187 ~MediaRoutesQuery(); |
| 190 | 188 |
| 191 // True if the query has been sent to the MRPM. False otherwise. | 189 // True if the query has been sent to the MRPM. False otherwise. |
| 192 bool is_active = false; | 190 bool is_active = false; |
| 191 |
| 192 // Cached list of routes and joinable route IDs for the query. |
| 193 base::Optional<std::vector<MediaRoute>> cached_route_list; |
| 194 std::vector<std::string> joinable_route_ids; |
| 195 |
| 193 base::ObserverList<MediaRoutesObserver> observers; | 196 base::ObserverList<MediaRoutesObserver> observers; |
| 194 | 197 |
| 195 private: | 198 private: |
| 196 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); | 199 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); |
| 197 }; | 200 }; |
| 198 | 201 |
| 199 // Standard constructor, used by | 202 // Standard constructor, used by |
| 200 // MediaRouterMojoImplFactory::GetApiForBrowserContext. | 203 // MediaRouterMojoImplFactory::GetApiForBrowserContext. |
| 201 explicit MediaRouterMojoImpl( | 204 explicit MediaRouterMojoImpl( |
| 202 extensions::EventPageTracker* event_page_tracker); | 205 extensions::EventPageTracker* event_page_tracker); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 225 // MediaRouter implementation. | 228 // MediaRouter implementation. |
| 226 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; | 229 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; |
| 227 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; | 230 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; |
| 228 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 231 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 229 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 232 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 230 void RegisterIssuesObserver(IssuesObserver* observer) override; | 233 void RegisterIssuesObserver(IssuesObserver* observer) override; |
| 231 void UnregisterIssuesObserver(IssuesObserver* observer) override; | 234 void UnregisterIssuesObserver(IssuesObserver* observer) override; |
| 232 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override; | 235 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override; |
| 233 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override; | 236 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override; |
| 234 | 237 |
| 238 // Notifies |observer| of any existing cached routes, if it is still |
| 239 // registered. |
| 240 void NotifyOfExistingRoutesIfRegistered(const MediaSource::Id& source_id, |
| 241 MediaRoutesObserver* observer) const; |
| 242 |
| 235 // These calls invoke methods in the component extension via Mojo. | 243 // These calls invoke methods in the component extension via Mojo. |
| 236 void DoCreateRoute(const MediaSource::Id& source_id, | 244 void DoCreateRoute(const MediaSource::Id& source_id, |
| 237 const MediaSink::Id& sink_id, | 245 const MediaSink::Id& sink_id, |
| 238 const url::Origin& origin, | 246 const url::Origin& origin, |
| 239 int tab_id, | 247 int tab_id, |
| 240 const std::vector<MediaRouteResponseCallback>& callbacks, | 248 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 241 base::TimeDelta timeout, | 249 base::TimeDelta timeout, |
| 242 bool incognito); | 250 bool incognito); |
| 243 void DoJoinRoute(const MediaSource::Id& source_id, | 251 void DoJoinRoute(const MediaSource::Id& source_id, |
| 244 const std::string& presentation_id, | 252 const std::string& presentation_id, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 #endif | 438 #endif |
| 431 | 439 |
| 432 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 440 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 433 | 441 |
| 434 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 442 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 435 }; | 443 }; |
| 436 | 444 |
| 437 } // namespace media_router | 445 } // namespace media_router |
| 438 | 446 |
| 439 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 447 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |