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

Unified Diff: chrome/browser/media/router/offscreen_presentation_manager.cc

Issue 2714783002: [Presentation API] (browser side) Implement reconnect() for 1-UA mode (Closed)
Patch Set: resolve code review comments from Derek Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/offscreen_presentation_manager.cc
diff --git a/chrome/browser/media/router/offscreen_presentation_manager.cc b/chrome/browser/media/router/offscreen_presentation_manager.cc
index 0e721ad4a3863a91a0454b1d440998d29b1cd42a..48d6fb10a8a39c16dcc624463a2ef4dc857e6209 100644
--- a/chrome/browser/media/router/offscreen_presentation_manager.cc
+++ b/chrome/browser/media/router/offscreen_presentation_manager.cc
@@ -39,16 +39,17 @@ void OffscreenPresentationManager::RegisterOffscreenPresentationController(
const GURL& presentation_url,
const RenderFrameHostId& render_frame_host_id,
content::PresentationConnectionPtr controller_connection_ptr,
- content::PresentationConnectionRequest receiver_connection_request) {
+ content::PresentationConnectionRequest receiver_connection_request,
+ const MediaRoute& route) {
DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id
<< ", [render_frame_host_id]: " << render_frame_host_id.second;
DCHECK(thread_checker_.CalledOnValidThread());
auto* presentation =
GetOrCreateOffscreenPresentation(presentation_id, presentation_url);
- presentation->RegisterController(render_frame_host_id,
- std::move(controller_connection_ptr),
- std::move(receiver_connection_request));
+ presentation->RegisterController(
+ render_frame_host_id, std::move(controller_connection_ptr),
+ std::move(receiver_connection_request), route);
}
void OffscreenPresentationManager::UnregisterOffscreenPresentationController(
@@ -90,6 +91,20 @@ void OffscreenPresentationManager::OnOffscreenPresentationReceiverTerminated(
offscreen_presentations_.erase(presentation_id);
}
+bool OffscreenPresentationManager::IsOffscreenPresentation(
+ const std::string& presentation_id) {
+ return base::ContainsKey(offscreen_presentations_, presentation_id);
+}
+
+const MediaRoute* OffscreenPresentationManager::GetRoute(
+ const std::string& presentation_id) {
+ auto it = offscreen_presentations_.find(presentation_id);
+ if (it == offscreen_presentations_.end())
mark a. foltz 2017/03/16 23:02:17 Nit: slight preference for ternary return.
zhaobin 2017/03/17 00:31:51 Done.
+ return nullptr;
+
+ return it->second->route_.get();
+}
+
// OffscreenPresentation implementation.
OffscreenPresentationManager::OffscreenPresentation::OffscreenPresentation(
const std::string& presentation_id,
@@ -101,7 +116,8 @@ OffscreenPresentationManager::OffscreenPresentation::~OffscreenPresentation() {}
void OffscreenPresentationManager::OffscreenPresentation::RegisterController(
const RenderFrameHostId& render_frame_host_id,
content::PresentationConnectionPtr controller_connection_ptr,
- content::PresentationConnectionRequest receiver_connection_request) {
+ content::PresentationConnectionRequest receiver_connection_request,
+ const MediaRoute& route) {
if (!receiver_callback_.is_null()) {
receiver_callback_.Run(
content::PresentationSessionInfo(presentation_url_, presentation_id_),
@@ -113,6 +129,12 @@ void OffscreenPresentationManager::OffscreenPresentation::RegisterController(
std::move(controller_connection_ptr),
std::move(receiver_connection_request))));
}
+
+ if (!route_)
+ route_ = base::MakeUnique<MediaRoute>(route);
mark a. foltz 2017/03/16 23:02:17 I wonder if this would work better as a base::Opti
zhaobin 2017/03/17 00:31:51 Done.
+
+ // Cannot have different routes for the same presentation id.
+ DCHECK(route_->Equals(route));
}
void OffscreenPresentationManager::OffscreenPresentation::UnregisterController(

Powered by Google App Engine
This is Rietveld 408576698