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_PRESENTATION_CONNECTION_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_CONNECTION_REQUEST_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_CONNECTION_REQUEST_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_CONNECTION_REQUEST_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // Holds parameters for creating a presentation session. | 29 // Holds parameters for creating a presentation session. |
30 // A request object is created by presentation_service_delegate_impl when it | 30 // A request object is created by presentation_service_delegate_impl when it |
31 // gets create-session request. The object is then passed to and owned by the | 31 // gets create-session request. The object is then passed to and owned by the |
32 // MediaRouterUI. |success_cb| will be invoked when create-session | 32 // MediaRouterUI. |success_cb| will be invoked when create-session |
33 // succeeds, or |error_cb| will be invoked when create-session fails or | 33 // succeeds, or |error_cb| will be invoked when create-session fails or |
34 // the UI closes. | 34 // the UI closes. |
35 class CreatePresentationConnectionRequest { | 35 class CreatePresentationConnectionRequest { |
36 public: | 36 public: |
37 using PresentationSessionSuccessCallback = | 37 using PresentationSessionSuccessCallback = |
38 base::Callback<void(const content::PresentationSessionInfo&, | 38 base::Callback<void(const content::PresentationSessionInfo&, |
39 const MediaRoute::Id&)>; | 39 const MediaRoute&)>; |
40 using PresentationSessionErrorCallback = | 40 using PresentationSessionErrorCallback = |
41 content::PresentationSessionErrorCallback; | 41 content::PresentationSessionErrorCallback; |
42 // |presentation_url|: The presentation URL of the request. Must be a valid | 42 // |presentation_url|: The presentation URL of the request. Must be a valid |
43 // URL. | 43 // URL. |
44 // |frame_url|: The URL of the frame that initiated the presentation request. | 44 // |frame_url|: The URL of the frame that initiated the presentation request. |
45 // |success_cb|: Callback to invoke when the request succeeds. Must be valid. | 45 // |success_cb|: Callback to invoke when the request succeeds. Must be valid. |
46 // |erorr_cb|: Callback to invoke when the request fails. Must be valid. | 46 // |erorr_cb|: Callback to invoke when the request fails. Must be valid. |
47 CreatePresentationConnectionRequest( | 47 CreatePresentationConnectionRequest( |
48 const RenderFrameHostId& render_frame_host_id, | 48 const RenderFrameHostId& render_frame_host_id, |
49 const GURL& presentation_url, | 49 const GURL& presentation_url, |
50 const GURL& frame_url, | 50 const GURL& frame_url, |
51 const PresentationSessionSuccessCallback& success_cb, | 51 const PresentationSessionSuccessCallback& success_cb, |
52 const PresentationSessionErrorCallback& error_cb); | 52 const PresentationSessionErrorCallback& error_cb); |
53 ~CreatePresentationConnectionRequest(); | 53 ~CreatePresentationConnectionRequest(); |
54 | 54 |
55 const PresentationRequest& presentation_request() const { | 55 const PresentationRequest& presentation_request() const { |
56 return presentation_request_; | 56 return presentation_request_; |
57 } | 57 } |
58 | 58 |
59 // Invokes |success_cb_| or |error_cb_| with the given arguments. | 59 // Invokes |success_cb_| or |error_cb_| with the given arguments. |
60 // These functions can only be invoked once per instance. It is an error | 60 // These functions can only be invoked once per instance. It is an error |
61 // to invoke these functions more than once. | 61 // to invoke these functions more than once. |
62 void InvokeSuccessCallback(const std::string& presentation_id, | 62 void InvokeSuccessCallback(const std::string& presentation_id, |
63 const MediaRoute::Id& route_id); | 63 const MediaRoute& route); |
64 void InvokeErrorCallback(const content::PresentationError& error); | 64 void InvokeErrorCallback(const content::PresentationError& error); |
65 | 65 |
66 // Handle route creation/joining response by invoking the right callback. | 66 // Handle route creation/joining response by invoking the right callback. |
67 static void HandleRouteResponse( | 67 static void HandleRouteResponse( |
68 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request, | 68 std::unique_ptr<CreatePresentationConnectionRequest> presentation_request, |
69 const RouteRequestResult& result); | 69 const RouteRequestResult& result); |
70 | 70 |
71 private: | 71 private: |
72 const PresentationRequest presentation_request_; | 72 const PresentationRequest presentation_request_; |
73 PresentationSessionSuccessCallback success_cb_; | 73 PresentationSessionSuccessCallback success_cb_; |
74 PresentationSessionErrorCallback error_cb_; | 74 PresentationSessionErrorCallback error_cb_; |
75 bool cb_invoked_; | 75 bool cb_invoked_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(CreatePresentationConnectionRequest); | 77 DISALLOW_COPY_AND_ASSIGN(CreatePresentationConnectionRequest); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace media_router | 80 } // namespace media_router |
81 | 81 |
82 #endif // CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_CONNECTION_REQUEST_H_ | 82 #endif // CHROME_BROWSER_MEDIA_ROUTER_CREATE_PRESENTATION_CONNECTION_REQUEST_H_ |
OLD | NEW |