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

Side by Side Diff: chrome/browser/media/router/create_presentation_connection_request.cc

Issue 2488403002: [Media Router] Handle multiple Presentation URLs when creating routes. (Closed)
Patch Set: Created 4 years, 1 month 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 #include "chrome/browser/media/router/create_presentation_connection_request.h" 5 #include "chrome/browser/media/router/create_presentation_connection_request.h"
6 6
7 #include "chrome/browser/media/router/media_source_helper.h" 7 #include "chrome/browser/media/router/media_source_helper.h"
8 #include "chrome/browser/media/router/route_request_result.h" 8 #include "chrome/browser/media/router/route_request_result.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
11 using content::PresentationSessionInfo; 11 using content::PresentationSessionInfo;
12 using content::PresentationError; 12 using content::PresentationError;
13 13
14 namespace media_router { 14 namespace media_router {
15 15
16 CreatePresentationConnectionRequest::CreatePresentationConnectionRequest( 16 CreatePresentationConnectionRequest::CreatePresentationConnectionRequest(
17 const RenderFrameHostId& render_frame_host_id, 17 const RenderFrameHostId& render_frame_host_id,
18 const GURL& presentation_url, 18 const vector<GURL>& presentation_urls,
19 const GURL& frame_url, 19 const GURL& frame_url,
20 const PresentationSessionSuccessCallback& success_cb, 20 const PresentationSessionSuccessCallback& success_cb,
21 const PresentationSessionErrorCallback& error_cb) 21 const PresentationSessionErrorCallback& error_cb)
22 : presentation_request_(render_frame_host_id, 22 : presentation_request_(render_frame_host_id,
23 {presentation_url}, 23 presentation_urls,
24 frame_url), 24 frame_url),
25 success_cb_(success_cb), 25 success_cb_(success_cb),
26 error_cb_(error_cb), 26 error_cb_(error_cb),
27 cb_invoked_(false) { 27 cb_invoked_(false) {
28 DCHECK(!success_cb.is_null()); 28 DCHECK(!success_cb.is_null());
29 DCHECK(!error_cb.is_null()); 29 DCHECK(!error_cb.is_null());
30 } 30 }
31 31
32 CreatePresentationConnectionRequest::~CreatePresentationConnectionRequest() { 32 CreatePresentationConnectionRequest::~CreatePresentationConnectionRequest() {
33 if (!cb_invoked_) { 33 if (!cb_invoked_) {
34 error_cb_.Run(content::PresentationError( 34 error_cb_.Run(content::PresentationError(
35 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error.")); 35 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error."));
36 } 36 }
37 } 37 }
38 38
39 void CreatePresentationConnectionRequest::InvokeSuccessCallback( 39 void CreatePresentationConnectionRequest::InvokeSuccessCallback(
40 const std::string& presentation_id, 40 const std::string& presentation_id,
41 const GURL& presentation_url,
41 const MediaRoute::Id& route_id) { 42 const MediaRoute::Id& route_id) {
42 DCHECK(!cb_invoked_); 43 DCHECK(!cb_invoked_);
43 if (!cb_invoked_) { 44 if (!cb_invoked_) {
44 success_cb_.Run( 45 success_cb_.Run(
45 content::PresentationSessionInfo( 46 content::PresentationSessionInfo(presentation_url, presentation_id),
46 presentation_request_.presentation_url(), presentation_id),
47 route_id); 47 route_id);
48 cb_invoked_ = true; 48 cb_invoked_ = true;
49 } 49 }
50 } 50 }
51 51
52 void CreatePresentationConnectionRequest::InvokeErrorCallback( 52 void CreatePresentationConnectionRequest::InvokeErrorCallback(
53 const content::PresentationError& error) { 53 const content::PresentationError& error) {
54 DCHECK(!cb_invoked_); 54 DCHECK(!cb_invoked_);
55 if (!cb_invoked_) { 55 if (!cb_invoked_) {
56 error_cb_.Run(error); 56 error_cb_.Run(error);
57 cb_invoked_ = true; 57 cb_invoked_ = true;
58 } 58 }
59 } 59 }
60 60
61 // static 61 // static
62 void CreatePresentationConnectionRequest::HandleRouteResponse( 62 void CreatePresentationConnectionRequest::HandleRouteResponse(
63 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request, 63 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request,
64 const RouteRequestResult& result) { 64 const RouteRequestResult& result) {
65 if (!result.route()) { 65 if (!result.route()) {
66 presentation_request->InvokeErrorCallback(content::PresentationError( 66 presentation_request->InvokeErrorCallback(content::PresentationError(
67 content::PRESENTATION_ERROR_UNKNOWN, result.error())); 67 content::PRESENTATION_ERROR_UNKNOWN, result.error()));
68 } else { 68 } else {
69 presentation_request->InvokeSuccessCallback( 69 presentation_request->InvokeSuccessCallback(
70 result.presentation_id(), result.route()->media_route_id()); 70 result.presentation_id(),
71 result.presentation_url(),
72 result.route()->media_route_id());
71 } 73 }
72 } 74 }
73 75
74 } // namespace media_router 76 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698