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

Side by Side Diff: chrome/browser/media/router/mojo/media_router_mojo_impl.h

Issue 2857393005: [Media Router] Sync state when MR extension is (re)connected to MR. (Closed)
Patch Set: Created 3 years, 7 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 | chrome/browser/media/router/mojo/media_router_mojo_impl.cc » ('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 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
148 DeferredBindingAndSuspension); 148 DeferredBindingAndSuspension);
149 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 149 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
150 DrainPendingRequestQueue); 150 DrainPendingRequestQueue);
151 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 151 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
152 DropOldestPendingRequest); 152 DropOldestPendingRequest);
153 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 153 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
154 AttemptedWakeupTooManyTimes); 154 AttemptedWakeupTooManyTimes);
155 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 155 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
156 WakeupFailedDrainsQueue); 156 WakeupFailedDrainsQueue);
157 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
158 SyncStateToMediaRouteProvider);
157 159
158 // The max number of pending requests allowed. When number of pending requests 160 // The max number of pending requests allowed. When number of pending requests
159 // exceeds this number, the oldest request will be dropped. 161 // exceeds this number, the oldest request will be dropped.
160 static const int kMaxPendingRequests = 30; 162 static const int kMaxPendingRequests = 30;
161 163
162 // Max consecutive attempts to wake up the component extension before 164 // Max consecutive attempts to wake up the component extension before
163 // giving up and draining the pending request queue. 165 // giving up and draining the pending request queue.
164 static const int kMaxWakeupAttemptCount = 3; 166 static const int kMaxWakeupAttemptCount = 3;
165 167
166 // Represents a query to the MRPM for media sinks and holds observers for the 168 // Represents a query to the MRPM for media sinks and holds observers for the
(...skipping 14 matching lines...) Expand all
181 183
182 private: 184 private:
183 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); 185 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery);
184 }; 186 };
185 187
186 struct MediaRoutesQuery { 188 struct MediaRoutesQuery {
187 public: 189 public:
188 MediaRoutesQuery(); 190 MediaRoutesQuery();
189 ~MediaRoutesQuery(); 191 ~MediaRoutesQuery();
190 192
191 // True if the query has been sent to the MRPM. False otherwise.
192 bool is_active = false;
193
194 // Cached list of routes and joinable route IDs for the query. 193 // Cached list of routes and joinable route IDs for the query.
195 base::Optional<std::vector<MediaRoute>> cached_route_list; 194 base::Optional<std::vector<MediaRoute>> cached_route_list;
196 std::vector<std::string> joinable_route_ids; 195 std::vector<std::string> joinable_route_ids;
197 196
198 base::ObserverList<MediaRoutesObserver> observers; 197 base::ObserverList<MediaRoutesObserver> observers;
199 198
200 private: 199 private:
201 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); 200 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery);
202 }; 201 };
203 202
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 const std::string& search_input, 284 const std::string& search_input,
286 const std::string& domain, 285 const std::string& domain,
287 const MediaSinkSearchResponseCallback& sink_callback); 286 const MediaSinkSearchResponseCallback& sink_callback);
288 287
289 void DoProvideSinks(const std::string& provider_name, 288 void DoProvideSinks(const std::string& provider_name,
290 const std::vector<MediaSinkInternal>& sinks); 289 const std::vector<MediaSinkInternal>& sinks);
291 290
292 // Error handler callback for |binding_| and |media_route_provider_|. 291 // Error handler callback for |binding_| and |media_route_provider_|.
293 void OnConnectionError(); 292 void OnConnectionError();
294 293
294 // Issues 0+ calls to |media_route_provider_| to ensure its state is in sync
295 // with MediaRouter on a best-effort basis. This method can be only called if
296 // |media_route_provider_| is a valid handle.
297 // The extension might have become out of sync with MediaRouter due to one
298 // of few reasons:
299 // (1) The extension crashed and lost unpersisted changes.
300 // (2) The extension was updated; temporary data is cleared.
301 // (3) The extension has an unforseen bug which causes temporary data to be
302 // persisted incorrectly on suspension.
303 void SyncStateToMediaRouteProvider();
304
295 // mojom::MediaRouter implementation. 305 // mojom::MediaRouter implementation.
296 void RegisterMediaRouteProvider( 306 void RegisterMediaRouteProvider(
297 mojom::MediaRouteProviderPtr media_route_provider_ptr, 307 mojom::MediaRouteProviderPtr media_route_provider_ptr,
298 const mojom::MediaRouter::RegisterMediaRouteProviderCallback& 308 const mojom::MediaRouter::RegisterMediaRouteProviderCallback&
299 callback) override; 309 callback) override;
300 void OnIssue(const IssueInfo& issue) override; 310 void OnIssue(const IssueInfo& issue) override;
301 void OnSinksReceived(const std::string& media_source, 311 void OnSinksReceived(const std::string& media_source,
302 const std::vector<MediaSinkInternal>& internal_sinks, 312 const std::vector<MediaSinkInternal>& internal_sinks,
303 const std::vector<url::Origin>& origins) override; 313 const std::vector<url::Origin>& origins) override;
304 void OnRoutesUpdated( 314 void OnRoutesUpdated(
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 #endif 453 #endif
444 454
445 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 455 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
446 456
447 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 457 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
448 }; 458 };
449 459
450 } // namespace media_router 460 } // namespace media_router
451 461
452 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ 462 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/router/mojo/media_router_mojo_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698