Chromium Code Reviews| 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> |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 158 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 159 DeferredBindingAndSuspension); | 159 DeferredBindingAndSuspension); |
| 160 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 160 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 161 DrainPendingRequestQueue); | 161 DrainPendingRequestQueue); |
| 162 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 162 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 163 DropOldestPendingRequest); | 163 DropOldestPendingRequest); |
| 164 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 164 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 165 AttemptedWakeupTooManyTimes); | 165 AttemptedWakeupTooManyTimes); |
| 166 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 166 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 167 WakeupFailedDrainsQueue); | 167 WakeupFailedDrainsQueue); |
| 168 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | |
| 169 SyncStateToMediaRouteProvider); | |
| 168 | 170 |
| 169 // The max number of pending requests allowed. When number of pending requests | 171 // The max number of pending requests allowed. When number of pending requests |
| 170 // exceeds this number, the oldest request will be dropped. | 172 // exceeds this number, the oldest request will be dropped. |
| 171 static const int kMaxPendingRequests = 30; | 173 static const int kMaxPendingRequests = 30; |
| 172 | 174 |
| 173 // Max consecutive attempts to wake up the component extension before | 175 // Max consecutive attempts to wake up the component extension before |
| 174 // giving up and draining the pending request queue. | 176 // giving up and draining the pending request queue. |
| 175 static const int kMaxWakeupAttemptCount = 3; | 177 static const int kMaxWakeupAttemptCount = 3; |
| 176 | 178 |
| 177 // Represents a query to the MRPM for media sinks and holds observers for the | 179 // Represents a query to the MRPM for media sinks and holds observers for the |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 192 | 194 |
| 193 private: | 195 private: |
| 194 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); | 196 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); |
| 195 }; | 197 }; |
| 196 | 198 |
| 197 struct MediaRoutesQuery { | 199 struct MediaRoutesQuery { |
| 198 public: | 200 public: |
| 199 MediaRoutesQuery(); | 201 MediaRoutesQuery(); |
| 200 ~MediaRoutesQuery(); | 202 ~MediaRoutesQuery(); |
| 201 | 203 |
| 202 // True if the query has been sent to the MRPM. False otherwise. | |
| 203 bool is_active = false; | |
| 204 | |
| 205 // Cached list of routes and joinable route IDs for the query. | 204 // Cached list of routes and joinable route IDs for the query. |
| 206 base::Optional<std::vector<MediaRoute>> cached_route_list; | 205 base::Optional<std::vector<MediaRoute>> cached_route_list; |
| 207 std::vector<std::string> joinable_route_ids; | 206 std::vector<std::string> joinable_route_ids; |
| 208 | 207 |
| 209 base::ObserverList<MediaRoutesObserver> observers; | 208 base::ObserverList<MediaRoutesObserver> observers; |
| 210 | 209 |
| 211 private: | 210 private: |
| 212 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); | 211 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); |
| 213 }; | 212 }; |
| 214 | 213 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 const MediaRoute::Id& route_id, | 301 const MediaRoute::Id& route_id, |
| 303 mojom::MediaControllerRequest mojo_media_controller_request, | 302 mojom::MediaControllerRequest mojo_media_controller_request, |
| 304 mojom::MediaStatusObserverPtr mojo_observer); | 303 mojom::MediaStatusObserverPtr mojo_observer); |
| 305 | 304 |
| 306 void DoProvideSinks(const std::string& provider_name, | 305 void DoProvideSinks(const std::string& provider_name, |
| 307 const std::vector<MediaSinkInternal>& sinks); | 306 const std::vector<MediaSinkInternal>& sinks); |
| 308 | 307 |
| 309 // Error handler callback for |binding_| and |media_route_provider_|. | 308 // Error handler callback for |binding_| and |media_route_provider_|. |
| 310 void OnConnectionError(); | 309 void OnConnectionError(); |
| 311 | 310 |
| 311 // Issues 0+ calls to |media_route_provider_| to ensure its state is in sync | |
| 312 // with MediaRouter on a best-effort basis. This method can be only called if | |
| 313 // |media_route_provider_| is a valid handle. | |
|
mark a. foltz
2017/05/03 17:37:08
Logically, this should be kicked off in RegisterMe
imcheng
2017/05/03 18:22:41
Correct. In other words, having a valid MRP handle
| |
| 314 // The extension might have become out of sync with MediaRouter due to one | |
| 315 // of few reasons: | |
| 316 // (1) The extension crashed and lost unpersisted changes. | |
| 317 // (2) The extension was updated; temporary data is cleared. | |
| 318 // (3) The extension has an unforseen bug which causes temporary data to be | |
| 319 // persisted incorrectly on suspension. | |
| 320 void EnsureMediaRouteProviderStateSynced(); | |
|
mark a. foltz
2017/05/03 17:37:08
Can this be a verb, i.e. SyncToMediaRouteProvider(
imcheng
2017/05/03 18:22:41
Renamed to SyncStateToMediaRouteProvider.
| |
| 321 | |
| 312 // mojom::MediaRouter implementation. | 322 // mojom::MediaRouter implementation. |
| 313 void RegisterMediaRouteProvider( | 323 void RegisterMediaRouteProvider( |
| 314 mojom::MediaRouteProviderPtr media_route_provider_ptr, | 324 mojom::MediaRouteProviderPtr media_route_provider_ptr, |
| 315 const mojom::MediaRouter::RegisterMediaRouteProviderCallback& | 325 const mojom::MediaRouter::RegisterMediaRouteProviderCallback& |
| 316 callback) override; | 326 callback) override; |
| 317 void OnIssue(const IssueInfo& issue) override; | 327 void OnIssue(const IssueInfo& issue) override; |
| 318 void OnSinksReceived(const std::string& media_source, | 328 void OnSinksReceived(const std::string& media_source, |
| 319 const std::vector<MediaSinkInternal>& internal_sinks, | 329 const std::vector<MediaSinkInternal>& internal_sinks, |
| 320 const std::vector<url::Origin>& origins) override; | 330 const std::vector<url::Origin>& origins) override; |
| 321 void OnRoutesUpdated( | 331 void OnRoutesUpdated( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 #endif | 481 #endif |
| 472 | 482 |
| 473 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 483 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 474 | 484 |
| 475 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 485 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 476 }; | 486 }; |
| 477 | 487 |
| 478 } // namespace media_router | 488 } // namespace media_router |
| 479 | 489 |
| 480 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 490 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |