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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_CREATE_SESSION_REQUEST_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_CREATE_SESSION_REQUEST_H_
10 #include "chrome/browser/media/router/media_source.h"
11 #include "content/public/browser/presentation_service_delegate.h"
15 struct PresentationError
;
16 struct PresentationSessionInfo
;
17 } // namespace content
19 namespace media_router
{
21 // Holds parameters for creating a presentation session.
22 // A request object is created by presentation_service_delegate_impl when it
23 // gets create-session request. The object is then passed to and owned by the
24 // MediaRouterUI. |success_cb| will be invoked when create-session
25 // succeeds, or |error_cb| will be invoked when create-session fails or
27 class CreateSessionRequest
{
29 using PresentationSessionSuccessCallback
=
30 content::PresentationServiceDelegate::PresentationSessionSuccessCallback
;
31 using PresentationSessionErrorCallback
=
32 content::PresentationServiceDelegate::PresentationSessionErrorCallback
;
34 // |presentation_url| must be valid.
35 CreateSessionRequest(const std::string
& presentation_url
,
36 const std::string
& presentation_id
,
37 const GURL
& frame_url
,
38 const PresentationSessionSuccessCallback
& success_cb
,
39 const PresentationSessionErrorCallback
& error_cb
);
40 ~CreateSessionRequest();
42 // Gets the MediaSource derived from this instance's presentation URL.
43 const MediaSource
& GetMediaSource() const { return media_source_
; }
45 const GURL
& frame_url() const { return frame_url_
; }
46 const content::PresentationSessionInfo
& presentation_info() const {
47 return presentation_info_
;
50 // Invokes |success_cb_| or |error_cb_| with the given arguments.
51 // These functions can only be invoked once per instance. Further invocations
53 void MaybeInvokeSuccessCallback();
54 void MaybeInvokeErrorCallback(const content::PresentationError
& error
);
57 content::PresentationSessionInfo presentation_info_
;
58 MediaSource media_source_
;
60 PresentationSessionSuccessCallback success_cb_
;
61 PresentationSessionErrorCallback error_cb_
;
64 DISALLOW_COPY_AND_ASSIGN(CreateSessionRequest
);
67 } // namespace media_router
69 #endif // CHROME_BROWSER_MEDIA_ROUTER_CREATE_SESSION_REQUEST_H_