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 CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
11 #include <set> | |
11 #include <string> | 12 #include <string> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/callback.h" | 15 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
16 #include "base/containers/hash_tables.h" | 17 #include "base/containers/hash_tables.h" |
17 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/memory/linked_ptr.h" | 20 #include "base/memory/linked_ptr.h" |
20 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
41 // It handles Presentation API requests coming from Blink / renderer process | 42 // It handles Presentation API requests coming from Blink / renderer process |
42 // and delegates the requests to the embedder's media router via | 43 // and delegates the requests to the embedder's media router via |
43 // PresentationServiceDelegate. | 44 // PresentationServiceDelegate. |
44 // An instance of this class tied to a RenderFrameHost and listens to events | 45 // An instance of this class tied to a RenderFrameHost and listens to events |
45 // related to the RFH via implementing WebContentsObserver. | 46 // related to the RFH via implementing WebContentsObserver. |
46 // This class is instantiated on-demand via Mojo's ConnectToRemoteService | 47 // This class is instantiated on-demand via Mojo's ConnectToRemoteService |
47 // from the renderer when the first presentation API request is handled. | 48 // from the renderer when the first presentation API request is handled. |
48 class CONTENT_EXPORT PresentationServiceImpl | 49 class CONTENT_EXPORT PresentationServiceImpl |
49 : public NON_EXPORTED_BASE(blink::mojom::PresentationService), | 50 : public NON_EXPORTED_BASE(blink::mojom::PresentationService), |
50 public WebContentsObserver, | 51 public WebContentsObserver, |
51 public PresentationServiceDelegate::Observer { | 52 public PresentationServiceDelegate::Observer, |
53 public OffscreenPresentationClient { | |
52 public: | 54 public: |
53 using NewSessionCallback = | 55 using NewSessionCallback = |
54 base::Callback<void(blink::mojom::PresentationSessionInfoPtr, | 56 base::Callback<void(blink::mojom::PresentationSessionInfoPtr, |
55 blink::mojom::PresentationErrorPtr)>; | 57 blink::mojom::PresentationErrorPtr)>; |
56 | 58 |
57 ~PresentationServiceImpl() override; | 59 ~PresentationServiceImpl() override; |
58 | 60 |
59 // Static factory method to create an instance of PresentationServiceImpl. | 61 // Static factory method to create an instance of PresentationServiceImpl. |
60 // |render_frame_host|: The RFH the instance is associated with. | 62 // |render_frame_host|: The RFH the instance is associated with. |
61 // |request|: The instance will be bound to this request. Used for Mojo setup. | 63 // |request|: The instance will be bound to this request. Used for Mojo setup. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 void ListenForConnectionStateChange( | 229 void ListenForConnectionStateChange( |
228 const PresentationSessionInfo& connection); | 230 const PresentationSessionInfo& connection); |
229 | 231 |
230 // Passed to embedder's implementation of PresentationServiceDelegate for | 232 // Passed to embedder's implementation of PresentationServiceDelegate for |
231 // later invocation when session messages arrive. | 233 // later invocation when session messages arrive. |
232 void OnSessionMessages( | 234 void OnSessionMessages( |
233 const content::PresentationSessionInfo& session, | 235 const content::PresentationSessionInfo& session, |
234 const ScopedVector<PresentationSessionMessage>& messages, | 236 const ScopedVector<PresentationSessionMessage>& messages, |
235 bool pass_ownership); | 237 bool pass_ownership); |
236 | 238 |
239 void OnReceiverConnectionAvailable(const content::PresentationSessionInfo&, | |
imcheng
2016/09/28 07:28:37
nit: add parameter name and add comment for this m
zhaobin
2016/09/29 17:20:45
Done.
| |
240 OffscreenPresentationClient* controller); | |
241 | |
242 // OffscreenPresentationClient Implementation | |
243 void SetOffscreenPresentationClient(OffscreenPresentationClient*) override; | |
imcheng
2016/09/28 07:28:37
nit: add parameter name here and below
imcheng
2016/09/28 07:28:37
AddOffscreenPresentationClient?
zhaobin
2016/09/29 17:20:45
code removed in new patch
zhaobin
2016/09/29 17:20:45
Function has been removed in new patch.
| |
244 | |
imcheng
2016/09/28 07:28:37
rm blank line
zhaobin
2016/09/29 17:20:45
Done.
| |
245 void RemoveOffscreenPresentationClient(OffscreenPresentationClient*) override; | |
246 | |
237 // Associates a JoinSession |callback| with a unique request ID and | 247 // Associates a JoinSession |callback| with a unique request ID and |
238 // stores it in a map. | 248 // stores it in a map. |
239 // Returns a positive value on success. | 249 // Returns a positive value on success. |
240 int RegisterJoinSessionCallback(const NewSessionCallback& callback); | 250 int RegisterJoinSessionCallback(const NewSessionCallback& callback); |
241 | 251 |
242 // Invoked by the embedder's PresentationServiceDelegate when a | 252 // Invoked by the embedder's PresentationServiceDelegate when a |
243 // PresentationConnection's state has changed. | 253 // PresentationConnection's state has changed. |
244 void OnConnectionStateChanged( | 254 void OnConnectionStateChanged( |
245 const PresentationSessionInfo& connection, | 255 const PresentationSessionInfo& connection, |
246 const PresentationConnectionStateChangeInfo& info); | 256 const PresentationConnectionStateChangeInfo& info); |
(...skipping 30 matching lines...) Expand all Loading... | |
277 | 287 |
278 // There can be only one send message request at a time. | 288 // There can be only one send message request at a time. |
279 std::unique_ptr<SendSessionMessageCallback> send_message_callback_; | 289 std::unique_ptr<SendSessionMessageCallback> send_message_callback_; |
280 | 290 |
281 std::unique_ptr<SessionMessagesCallback> on_session_messages_callback_; | 291 std::unique_ptr<SessionMessagesCallback> on_session_messages_callback_; |
282 | 292 |
283 // ID of the RenderFrameHost this object is associated with. | 293 // ID of the RenderFrameHost this object is associated with. |
284 int render_process_id_; | 294 int render_process_id_; |
285 int render_frame_id_; | 295 int render_frame_id_; |
286 | 296 |
297 // Offscreen presentation observer list for current frame. | |
298 // For controller PSImpl, it contains corresponding receiver PSImpl, | |
299 // and vise versa. | |
300 // TODO(zhaobin): support multiple controllers | |
301 std::set<OffscreenPresentationClient*> offscreen_presentation_observers_; | |
imcheng
2016/09/28 07:28:37
suggestion: offscreen_presentation_clients_
imcheng
2016/09/28 07:28:37
nit: Place this field before render_process_id_. P
zhaobin
2016/09/29 17:20:45
object removed in new patch
zhaobin
2016/09/29 17:20:45
object removed in new patch
| |
302 | |
287 // NOTE: Weak pointers must be invalidated before all other member variables. | 303 // NOTE: Weak pointers must be invalidated before all other member variables. |
288 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 304 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
289 | 305 |
290 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 306 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
291 }; | 307 }; |
292 | 308 |
293 } // namespace content | 309 } // namespace content |
294 | 310 |
295 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 311 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
OLD | NEW |