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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_CREATE_SESSION_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_SESSION_REQUEST_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_CREATE_SESSION_REQUEST_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_SESSION_REQUEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/media/router/media_route.h" | 10 #include "chrome/browser/media/router/media_route.h" |
11 #include "chrome/browser/media/router/media_source.h" | 11 #include "chrome/browser/media/router/media_source.h" |
12 #include "content/public/browser/presentation_service_delegate.h" | 12 #include "content/public/browser/presentation_service_delegate.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 struct PresentationError; | 16 struct PresentationError; |
17 struct PresentationSessionInfo; | 17 struct PresentationSessionInfo; |
18 } // namespace content | 18 } // namespace content |
19 | 19 |
20 namespace media_router { | 20 namespace media_router { |
21 | 21 |
22 // Holds parameters for creating a presentation session. | 22 // Holds parameters for creating a presentation session. |
23 // A request object is created by presentation_service_delegate_impl when it | 23 // A request object is created by presentation_service_delegate_impl when it |
24 // gets create-session request. The object is then passed to and owned by the | 24 // gets create-session request. The object is then passed to and owned by the |
25 // MediaRouterUI. |success_cb| will be invoked when create-session | 25 // MediaRouterUI. |success_cb| will be invoked when create-session |
26 // succeeds, or |error_cb| will be invoked when create-session fails or | 26 // succeeds, or |error_cb| will be invoked when create-session fails or |
27 // the UI closes. | 27 // the UI closes. |
28 class CreateSessionRequest { | 28 class CreatePresentationSessionRequest { |
29 public: | 29 public: |
30 using PresentationSessionSuccessCallback = | 30 using PresentationSessionSuccessCallback = |
31 base::Callback<void(const content::PresentationSessionInfo&, | 31 base::Callback<void(const content::PresentationSessionInfo&, |
32 const MediaRoute::Id&)>; | 32 const MediaRoute::Id&)>; |
33 using PresentationSessionErrorCallback = | 33 using PresentationSessionErrorCallback = |
34 content::PresentationServiceDelegate::PresentationSessionErrorCallback; | 34 content::PresentationServiceDelegate::PresentationSessionErrorCallback; |
35 | 35 |
36 // |presentation_url| must be valid. | 36 // |presentation_url| must be valid. |
37 CreateSessionRequest(const std::string& presentation_url, | 37 CreatePresentationSessionRequest( |
38 const std::string& presentation_id, | 38 const std::string& presentation_url, |
39 const GURL& frame_url, | 39 const std::string& presentation_id, |
40 const PresentationSessionSuccessCallback& success_cb, | 40 const GURL& frame_url, |
41 const PresentationSessionErrorCallback& error_cb); | 41 const PresentationSessionSuccessCallback& success_cb, |
42 ~CreateSessionRequest(); | 42 const PresentationSessionErrorCallback& error_cb); |
| 43 ~CreatePresentationSessionRequest(); |
43 | 44 |
44 // Gets the MediaSource derived from this instance's presentation URL. | 45 // Gets the MediaSource derived from this instance's presentation URL. |
45 const MediaSource& GetMediaSource() const { return media_source_; } | 46 const MediaSource& GetMediaSource() const { return media_source_; } |
46 | 47 |
47 const GURL& frame_url() const { return frame_url_; } | 48 const GURL& frame_url() const { return frame_url_; } |
48 const content::PresentationSessionInfo& presentation_info() const { | 49 const content::PresentationSessionInfo& presentation_info() const { |
49 return presentation_info_; | 50 return presentation_info_; |
50 } | 51 } |
51 | 52 |
52 // Invokes |success_cb_| or |error_cb_| with the given arguments. | 53 // Invokes |success_cb_| or |error_cb_| with the given arguments. |
53 // These functions can only be invoked once per instance. Further invocations | 54 // These functions can only be invoked once per instance. Further invocations |
54 // are no-op. | 55 // are no-op. |
55 void MaybeInvokeSuccessCallback(const MediaRoute::Id& route_id); | 56 void MaybeInvokeSuccessCallback(const MediaRoute::Id& route_id); |
56 void MaybeInvokeErrorCallback(const content::PresentationError& error); | 57 void MaybeInvokeErrorCallback(const content::PresentationError& error); |
57 | 58 |
58 private: | 59 private: |
59 content::PresentationSessionInfo presentation_info_; | 60 content::PresentationSessionInfo presentation_info_; |
60 MediaSource media_source_; | 61 MediaSource media_source_; |
61 GURL frame_url_; | 62 GURL frame_url_; |
62 PresentationSessionSuccessCallback success_cb_; | 63 PresentationSessionSuccessCallback success_cb_; |
63 PresentationSessionErrorCallback error_cb_; | 64 PresentationSessionErrorCallback error_cb_; |
64 bool cb_invoked_; | 65 bool cb_invoked_; |
65 | 66 |
66 DISALLOW_COPY_AND_ASSIGN(CreateSessionRequest); | 67 DISALLOW_COPY_AND_ASSIGN(CreatePresentationSessionRequest); |
67 }; | 68 }; |
68 | 69 |
69 } // namespace media_router | 70 } // namespace media_router |
70 | 71 |
71 #endif // CHROME_BROWSER_MEDIA_ROUTER_CREATE_SESSION_REQUEST_H_ | 72 #endif // CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_SESSION_REQUEST_H_ |
OLD | NEW |