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

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

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: merge with master 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
(...skipping 20 matching lines...) Expand all
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 MediaRoute::Id& route_id) { 41 const MediaRoute& route) {
42 DCHECK(!cb_invoked_); 42 DCHECK(!cb_invoked_);
43 if (!cb_invoked_) { 43 if (!cb_invoked_) {
44 success_cb_.Run( 44 success_cb_.Run(content::PresentationSessionInfo(
45 content::PresentationSessionInfo( 45 presentation_request_.presentation_url(),
46 presentation_request_.presentation_url(), presentation_id), 46 presentation_id, route.is_offscreen_presentation()),
47 route_id); 47 route);
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(result.presentation_id(),
70 result.presentation_id(), result.route()->media_route_id()); 70 *result.route());
71 } 71 }
72 } 72 }
73 73
74 } // namespace media_router 74 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698