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

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

Issue 2547703002: [Media Router] Handle multiple Presentation URLs when creating routes (Closed)
Patch Set: rebase Created 4 years 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 std::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, presentation_urls, frame_url),
23 {presentation_url},
24 frame_url),
25 success_cb_(success_cb), 23 success_cb_(success_cb),
26 error_cb_(error_cb), 24 error_cb_(error_cb),
27 cb_invoked_(false) { 25 cb_invoked_(false) {
28 DCHECK(!success_cb.is_null()); 26 DCHECK(!success_cb.is_null());
29 DCHECK(!error_cb.is_null()); 27 DCHECK(!error_cb.is_null());
30 } 28 }
31 29
32 CreatePresentationConnectionRequest::~CreatePresentationConnectionRequest() { 30 CreatePresentationConnectionRequest::~CreatePresentationConnectionRequest() {
33 if (!cb_invoked_) { 31 if (!cb_invoked_) {
34 error_cb_.Run(content::PresentationError( 32 error_cb_.Run(content::PresentationError(
35 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error.")); 33 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error."));
36 } 34 }
37 } 35 }
38 36
39 void CreatePresentationConnectionRequest::InvokeSuccessCallback( 37 void CreatePresentationConnectionRequest::InvokeSuccessCallback(
40 const std::string& presentation_id, 38 const std::string& presentation_id,
39 const GURL& presentation_url,
41 const MediaRoute& route) { 40 const MediaRoute& route) {
42 DCHECK(!cb_invoked_); 41 DCHECK(!cb_invoked_);
43 if (!cb_invoked_) { 42 if (!cb_invoked_) {
44 success_cb_.Run( 43 success_cb_.Run(
45 content::PresentationSessionInfo( 44 content::PresentationSessionInfo(presentation_url, presentation_id),
46 presentation_request_.presentation_url(), presentation_id),
47 route); 45 route);
48 cb_invoked_ = true; 46 cb_invoked_ = true;
49 } 47 }
50 } 48 }
51 49
52 void CreatePresentationConnectionRequest::InvokeErrorCallback( 50 void CreatePresentationConnectionRequest::InvokeErrorCallback(
53 const content::PresentationError& error) { 51 const content::PresentationError& error) {
54 DCHECK(!cb_invoked_); 52 DCHECK(!cb_invoked_);
55 if (!cb_invoked_) { 53 if (!cb_invoked_) {
56 error_cb_.Run(error); 54 error_cb_.Run(error);
57 cb_invoked_ = true; 55 cb_invoked_ = true;
58 } 56 }
59 } 57 }
60 58
61 // static 59 // static
62 void CreatePresentationConnectionRequest::HandleRouteResponse( 60 void CreatePresentationConnectionRequest::HandleRouteResponse(
63 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request, 61 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request,
64 const RouteRequestResult& result) { 62 const RouteRequestResult& result) {
65 if (!result.route()) { 63 if (!result.route()) {
66 presentation_request->InvokeErrorCallback(content::PresentationError( 64 presentation_request->InvokeErrorCallback(content::PresentationError(
67 content::PRESENTATION_ERROR_UNKNOWN, result.error())); 65 content::PRESENTATION_ERROR_UNKNOWN, result.error()));
68 } else { 66 } else {
69 presentation_request->InvokeSuccessCallback(result.presentation_id(), 67 presentation_request->InvokeSuccessCallback(
70 *result.route()); 68 result.presentation_id(), result.presentation_url(), *result.route());
71 } 69 }
72 } 70 }
73 71
74 } // namespace media_router 72 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698