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

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

Issue 1224093004: [Media Router] 2nd take on fix route response callback lifetime in UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Kevin's comments Created 5 years, 5 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_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,
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),
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 if (!cb_invoked_) {
mark a. foltz 2015/07/14 21:36:32 Or just call MaybeInvokeErrorCallback()?
30 error_cb_.Run(content::PresentationError(
31 content::PRESENTATION_ERROR_UNKNOWN, "Unknown error."));
32 }
29 } 33 }
30 34
31 void CreateSessionRequest::MaybeInvokeSuccessCallback( 35 void CreateSessionRequest::MaybeInvokeSuccessCallback(
32 const MediaRoute::Id& route_id) { 36 const MediaRoute::Id& route_id) {
33 if (!cb_invoked_) { 37 if (!cb_invoked_) {
34 // Overwrite presentation ID. 38 // Overwrite presentation ID.
35 success_cb_.Run(content::PresentationSessionInfo( 39 success_cb_.Run(content::PresentationSessionInfo(
36 presentation_info_.presentation_url, 40 presentation_info_.presentation_url,
37 GetPresentationIdAndUrl(route_id).first), 41 GetPresentationIdAndUrl(route_id).first),
38 route_id); 42 route_id);
39 cb_invoked_ = true; 43 cb_invoked_ = true;
40 } 44 }
41 } 45 }
42 46
43 void CreateSessionRequest::MaybeInvokeErrorCallback( 47 void CreateSessionRequest::MaybeInvokeErrorCallback(
44 const content::PresentationError& error) { 48 const content::PresentationError& error) {
45 if (!cb_invoked_) { 49 if (!cb_invoked_) {
46 error_cb_.Run(error); 50 error_cb_.Run(error);
47 cb_invoked_ = true; 51 cb_invoked_ = true;
48 } 52 }
49 } 53 }
50 54
51 } // namespace media_router 55 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698