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