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

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

Issue 1406013003: [Presentation API / Media Router] Clean up default pres URL logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Original patch Created 5 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_session_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 8
9 using content::PresentationSessionInfo; 9 using content::PresentationSessionInfo;
10 using content::PresentationError; 10 using content::PresentationError;
11 11
12 namespace media_router { 12 namespace media_router {
13 13
14 CreatePresentationSessionRequest::CreatePresentationSessionRequest( 14 CreatePresentationConnectionRequest::CreatePresentationConnectionRequest(
15 const RenderFrameHostId& render_frame_host_id,
15 const std::string& presentation_url, 16 const std::string& presentation_url,
16 const GURL& frame_url, 17 const GURL& frame_url,
17 const PresentationSessionSuccessCallback& success_cb, 18 const PresentationSessionSuccessCallback& success_cb,
18 const PresentationSessionErrorCallback& error_cb) 19 const PresentationSessionErrorCallback& error_cb)
19 : media_source_(MediaSourceForPresentationUrl(presentation_url)), 20 : presentation_request_(render_frame_host_id, presentation_url, frame_url),
20 frame_url_(frame_url),
21 success_cb_(success_cb), 21 success_cb_(success_cb),
22 error_cb_(error_cb), 22 error_cb_(error_cb),
23 cb_invoked_(false) { 23 cb_invoked_(false) {
24 DCHECK(!success_cb.is_null()); 24 DCHECK(!success_cb.is_null());
25 DCHECK(!error_cb.is_null()); 25 DCHECK(!error_cb.is_null());
26 } 26 }
27 27
28 CreatePresentationSessionRequest::~CreatePresentationSessionRequest() { 28 CreatePresentationConnectionRequest::~CreatePresentationConnectionRequest() {
29 if (!cb_invoked_) { 29 if (!cb_invoked_) {
30 error_cb_.Run(content::PresentationError( 30 error_cb_.Run(content::PresentationError(
31 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error.")); 31 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error."));
32 } 32 }
33 } 33 }
34 34
35 void CreatePresentationSessionRequest::InvokeSuccessCallback( 35 void CreatePresentationConnectionRequest::InvokeSuccessCallback(
36 const std::string& presentation_id, 36 const std::string& presentation_id,
37 const MediaRoute::Id& route_id) { 37 const MediaRoute::Id& route_id) {
38 DCHECK(!cb_invoked_); 38 DCHECK(!cb_invoked_);
39 if (!cb_invoked_) { 39 if (!cb_invoked_) {
40 // Overwrite presentation ID.
41 success_cb_.Run( 40 success_cb_.Run(
42 content::PresentationSessionInfo( 41 content::PresentationSessionInfo(
43 PresentationUrlFromMediaSource(media_source_), presentation_id), 42 presentation_request_.presentation_url(), presentation_id),
44 route_id); 43 route_id);
45 cb_invoked_ = true; 44 cb_invoked_ = true;
46 } 45 }
47 } 46 }
48 47
49 void CreatePresentationSessionRequest::InvokeErrorCallback( 48 void CreatePresentationConnectionRequest::InvokeErrorCallback(
50 const content::PresentationError& error) { 49 const content::PresentationError& error) {
51 DCHECK(!cb_invoked_); 50 DCHECK(!cb_invoked_);
52 if (!cb_invoked_) { 51 if (!cb_invoked_) {
53 error_cb_.Run(error); 52 error_cb_.Run(error);
54 cb_invoked_ = true; 53 cb_invoked_ = true;
55 } 54 }
56 } 55 }
57 56
58 // static 57 // static
59 void CreatePresentationSessionRequest::HandleRouteResponse( 58 void CreatePresentationConnectionRequest::HandleRouteResponse(
60 scoped_ptr<CreatePresentationSessionRequest> presentation_request, 59 scoped_ptr<CreatePresentationConnectionRequest> presentation_request,
61 const MediaRoute* route, 60 const MediaRoute* route,
62 const std::string& presentation_id, 61 const std::string& presentation_id,
63 const std::string& error) { 62 const std::string& error) {
64 if (!route) { 63 if (!route) {
65 presentation_request->InvokeErrorCallback( 64 presentation_request->InvokeErrorCallback(
66 content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, error)); 65 content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, error));
67 } else { 66 } else {
68 presentation_request->InvokeSuccessCallback(presentation_id, 67 presentation_request->InvokeSuccessCallback(presentation_id,
69 route->media_route_id()); 68 route->media_route_id());
70 } 69 }
71 } 70 }
72 71
73 } // namespace media_router 72 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698