Chromium Code Reviews| 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_session_request.h" | 5 #include "chrome/browser/media/router/create_session_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 CreateSessionRequest::CreateSessionRequest( | 14 CreateSessionRequest::CreateSessionRequest( |
| 15 const std::string& presentation_url, | 15 const std::string& presentation_url, |
| 16 const std::string& presentation_id, | 16 const std::string& presentation_id, |
|
Kevin M
2015/06/24 23:02:06
Remove this? I don't see any users of this data...
| |
| 17 const GURL& frame_url, | 17 const GURL& frame_url, |
| 18 const PresentationSessionSuccessCallback& success_cb, | 18 const PresentationSessionSuccessCallback& success_cb, |
| 19 const PresentationSessionErrorCallback& error_cb) | 19 const PresentationSessionErrorCallback& error_cb) |
| 20 : presentation_info_(presentation_url, presentation_id), | 20 : presentation_info_(presentation_url, presentation_id), |
|
Kevin M
2015/06/24 23:02:06
Should be removed, there are no clients of it.
| |
| 21 media_source_(presentation_url), | 21 media_source_(presentation_url), |
| 22 frame_url_(frame_url), | 22 frame_url_(frame_url), |
| 23 success_cb_(success_cb), | 23 success_cb_(success_cb), |
| 24 error_cb_(error_cb), | 24 error_cb_(error_cb), |
| 25 cb_invoked_(false) { | 25 cb_invoked_(false) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 CreateSessionRequest::~CreateSessionRequest() { | 28 CreateSessionRequest::~CreateSessionRequest() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 void CreateSessionRequest::MaybeInvokeSuccessCallback( | 31 void CreateSessionRequest::MaybeInvokeSuccessCallback( |
| 32 const MediaRoute::Id& route_id) { | 32 const MediaRoute::Id& route_id) { |
| 33 if (!cb_invoked_) { | 33 if (!cb_invoked_) { |
| 34 success_cb_.Run(presentation_info_, route_id); | 34 // Overwrite presentation ID. |
| 35 success_cb_.Run(content::PresentationSessionInfo( | |
| 36 presentation_info_.presentation_url, | |
| 37 GetPresentationIdAndUrl(route_id).first), | |
| 38 route_id); | |
| 35 cb_invoked_ = true; | 39 cb_invoked_ = true; |
| 36 } | 40 } |
| 37 } | 41 } |
| 38 | 42 |
| 39 void CreateSessionRequest::MaybeInvokeErrorCallback( | 43 void CreateSessionRequest::MaybeInvokeErrorCallback( |
| 40 const content::PresentationError& error) { | 44 const content::PresentationError& error) { |
| 41 if (!cb_invoked_) { | 45 if (!cb_invoked_) { |
| 42 error_cb_.Run(error); | 46 error_cb_.Run(error); |
| 43 cb_invoked_ = true; | 47 cb_invoked_ = true; |
| 44 } | 48 } |
| 45 } | 49 } |
| 46 | 50 |
| 47 } // namespace media_router | 51 } // namespace media_router |
| OLD | NEW |