| OLD | NEW |
| 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 | 9 |
| 10 using content::PresentationSessionInfo; | 10 using content::PresentationSessionInfo; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 CreatePresentationConnectionRequest::~CreatePresentationConnectionRequest() { | 29 CreatePresentationConnectionRequest::~CreatePresentationConnectionRequest() { |
| 30 if (!cb_invoked_) { | 30 if (!cb_invoked_) { |
| 31 error_cb_.Run(content::PresentationError( | 31 error_cb_.Run(content::PresentationError( |
| 32 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error.")); | 32 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error.")); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 void CreatePresentationConnectionRequest::InvokeSuccessCallback( | 36 void CreatePresentationConnectionRequest::InvokeSuccessCallback( |
| 37 const std::string& presentation_id, | 37 const std::string& presentation_id, |
| 38 const MediaRoute::Id& route_id) { | 38 const MediaRoute& route) { |
| 39 DCHECK(!cb_invoked_); | 39 DCHECK(!cb_invoked_); |
| 40 if (!cb_invoked_) { | 40 if (!cb_invoked_) { |
| 41 success_cb_.Run( | 41 success_cb_.Run( |
| 42 content::PresentationSessionInfo( | 42 content::PresentationSessionInfo( |
| 43 presentation_request_.presentation_url(), presentation_id), | 43 presentation_request_.presentation_url(), presentation_id), |
| 44 route_id); | 44 route); |
| 45 cb_invoked_ = true; | 45 cb_invoked_ = true; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 void CreatePresentationConnectionRequest::InvokeErrorCallback( | 49 void CreatePresentationConnectionRequest::InvokeErrorCallback( |
| 50 const content::PresentationError& error) { | 50 const content::PresentationError& error) { |
| 51 DCHECK(!cb_invoked_); | 51 DCHECK(!cb_invoked_); |
| 52 if (!cb_invoked_) { | 52 if (!cb_invoked_) { |
| 53 error_cb_.Run(error); | 53 error_cb_.Run(error); |
| 54 cb_invoked_ = true; | 54 cb_invoked_ = true; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 void CreatePresentationConnectionRequest::HandleRouteResponse( | 59 void CreatePresentationConnectionRequest::HandleRouteResponse( |
| 60 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request, | 60 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request, |
| 61 const RouteRequestResult& result) { | 61 const RouteRequestResult& result) { |
| 62 if (!result.route()) { | 62 if (!result.route()) { |
| 63 presentation_request->InvokeErrorCallback(content::PresentationError( | 63 presentation_request->InvokeErrorCallback(content::PresentationError( |
| 64 content::PRESENTATION_ERROR_UNKNOWN, result.error())); | 64 content::PRESENTATION_ERROR_UNKNOWN, result.error())); |
| 65 } else { | 65 } else { |
| 66 presentation_request->InvokeSuccessCallback( | 66 presentation_request->InvokeSuccessCallback(result.presentation_id(), |
| 67 result.presentation_id(), result.route()->media_route_id()); | 67 *result.route()); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace media_router | 71 } // namespace media_router |
| OLD | NEW |