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

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

Issue 2737413003: [Presentation API] Remove references to presentation sessions. (Closed)
Patch Set: Update PresentationServiceDelegateImpl unittest 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 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/origin.h" 9 #include "url/origin.h"
10 10
11 using content::PresentationSessionInfo; 11 using content::PresentationInfo;
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 std::vector<GURL>& presentation_urls, 18 const std::vector<GURL>& presentation_urls,
19 const url::Origin& frame_origin, 19 const url::Origin& frame_origin,
20 const PresentationSessionSuccessCallback& success_cb, 20 const PresentationConnectionCallback& success_cb,
21 const PresentationSessionErrorCallback& error_cb) 21 const PresentationConnectionErrorCallback& error_cb)
22 : presentation_request_(render_frame_host_id, 22 : presentation_request_(render_frame_host_id,
23 presentation_urls, 23 presentation_urls,
24 frame_origin), 24 frame_origin),
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 GURL& presentation_url,
42 const MediaRoute& route) { 42 const MediaRoute& route) {
43 DCHECK(!cb_invoked_); 43 DCHECK(!cb_invoked_);
44 if (!cb_invoked_) { 44 if (!cb_invoked_) {
45 success_cb_.Run( 45 success_cb_.Run(
46 content::PresentationSessionInfo(presentation_url, presentation_id), 46 content::PresentationInfo(presentation_url, presentation_id), route);
47 route);
48 cb_invoked_ = true; 47 cb_invoked_ = true;
49 } 48 }
50 } 49 }
51 50
52 void CreatePresentationConnectionRequest::InvokeErrorCallback( 51 void CreatePresentationConnectionRequest::InvokeErrorCallback(
53 const content::PresentationError& error) { 52 const content::PresentationError& error) {
54 DCHECK(!cb_invoked_); 53 DCHECK(!cb_invoked_);
55 if (!cb_invoked_) { 54 if (!cb_invoked_) {
56 error_cb_.Run(error); 55 error_cb_.Run(error);
57 cb_invoked_ = true; 56 cb_invoked_ = true;
58 } 57 }
59 } 58 }
60 59
61 // static 60 // static
62 void CreatePresentationConnectionRequest::HandleRouteResponse( 61 void CreatePresentationConnectionRequest::HandleRouteResponse(
63 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request, 62 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request,
64 const RouteRequestResult& result) { 63 const RouteRequestResult& result) {
65 if (!result.route()) { 64 if (!result.route()) {
66 presentation_request->InvokeErrorCallback(content::PresentationError( 65 presentation_request->InvokeErrorCallback(content::PresentationError(
67 content::PRESENTATION_ERROR_UNKNOWN, result.error())); 66 content::PRESENTATION_ERROR_UNKNOWN, result.error()));
68 } else { 67 } else {
69 presentation_request->InvokeSuccessCallback( 68 presentation_request->InvokeSuccessCallback(
70 result.presentation_id(), result.presentation_url(), *result.route()); 69 result.presentation_id(), result.presentation_url(), *result.route());
71 } 70 }
72 } 71 }
73 72
74 } // namespace media_router 73 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698