Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: content/browser/presentation/presentation_service_impl.h

Issue 1118103002: Implements ListenForSessionMessages in PresentationServiceImpl; uses Swap to avoid copying large da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/public/browser/navigation_details.h" 21 #include "content/public/browser/navigation_details.h"
22 #include "content/public/browser/presentation_screen_availability_listener.h" 22 #include "content/public/browser/presentation_screen_availability_listener.h"
23 #include "content/public/browser/presentation_service_delegate.h" 23 #include "content/public/browser/presentation_service_delegate.h"
24 #include "content/public/browser/web_contents_observer.h" 24 #include "content/public/browser/web_contents_observer.h"
25 #include "content/public/common/frame_navigate_params.h" 25 #include "content/public/common/frame_navigate_params.h"
26 26
27 namespace content { 27 namespace content {
28 28
29 struct FrameNavigateParams; 29 struct FrameNavigateParams;
30 struct LoadCommittedDetails; 30 struct LoadCommittedDetails;
31 struct PresentationSessionMessage;
31 class RenderFrameHost; 32 class RenderFrameHost;
32 33
33 // Implementation of Mojo PresentationService. 34 // Implementation of Mojo PresentationService.
34 // It handles Presentation API requests coming from Blink / renderer process 35 // It handles Presentation API requests coming from Blink / renderer process
35 // and delegates the requests to the embedder's media router via 36 // and delegates the requests to the embedder's media router via
36 // PresentationServiceDelegate. 37 // PresentationServiceDelegate.
37 // An instance of this class tied to a RenderFrameHost and listens to events 38 // An instance of this class tied to a RenderFrameHost and listens to events
38 // related to the RFH via implementing WebContentsObserver. 39 // related to the RFH via implementing WebContentsObserver.
39 // This class is instantiated on-demand via Mojo's ConnectToRemoteService 40 // This class is instantiated on-demand via Mojo's ConnectToRemoteService
40 // from the renderer when the first presentation API request is handled. 41 // from the renderer when the first presentation API request is handled.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 169 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
169 SetSameDefaultPresentationUrl); 170 SetSameDefaultPresentationUrl);
170 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 171 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
171 ClearDefaultPresentationUrl); 172 ClearDefaultPresentationUrl);
172 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 173 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
173 ListenForDefaultSessionStart); 174 ListenForDefaultSessionStart);
174 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 175 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
175 ListenForDefaultSessionStartAfterSet); 176 ListenForDefaultSessionStartAfterSet);
176 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 177 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
177 DefaultSessionStartReset); 178 DefaultSessionStartReset);
179 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
180 ReceiveSessionMessagesAfterReset);
178 181
179 // |render_frame_host|: The RFH this instance is associated with. 182 // |render_frame_host|: The RFH this instance is associated with.
180 // |web_contents|: The WebContents to observe. 183 // |web_contents|: The WebContents to observe.
181 // |delegate|: Where Presentation API requests are delegated to. Not owned 184 // |delegate|: Where Presentation API requests are delegated to. Not owned
182 // by this class. 185 // by this class.
183 PresentationServiceImpl( 186 PresentationServiceImpl(
184 RenderFrameHost* render_frame_host, 187 RenderFrameHost* render_frame_host,
185 WebContents* web_contents, 188 WebContents* web_contents,
186 PresentationServiceDelegate* delegate); 189 PresentationServiceDelegate* delegate);
187 190
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bool is_start_session, 263 bool is_start_session,
261 int request_session_id, 264 int request_session_id,
262 const PresentationError& error); 265 const PresentationError& error);
263 266
264 // Requests delegate to start a session. 267 // Requests delegate to start a session.
265 void DoStartSession( 268 void DoStartSession(
266 const std::string& presentation_url, 269 const std::string& presentation_url,
267 const std::string& presentation_id, 270 const std::string& presentation_id,
268 const NewSessionMojoCallback& callback); 271 const NewSessionMojoCallback& callback);
269 272
273 // Passed to embedder's implementation of PresentationServiceDelegate for
274 // later invocation when session messages arrive.
275 // For optimization purposes, this method will empty the messages
276 // passed to it.
277 void OnSessionMessages(
278 scoped_ptr<ScopedVector<PresentationSessionMessage>> messages);
279
270 // Removes the head of the queue (which represents the request that has just 280 // Removes the head of the queue (which represents the request that has just
271 // been processed). 281 // been processed).
272 // Checks if there are any queued StartSession requests and if so, executes 282 // Checks if there are any queued StartSession requests and if so, executes
273 // the first one in the queue. 283 // the first one in the queue.
274 void HandleQueuedStartSessionRequests(); 284 void HandleQueuedStartSessionRequests();
275 285
276 // Associates |callback| with a unique request ID and stores it in a map. 286 // Associates |callback| with a unique request ID and stores it in a map.
277 int RegisterNewSessionCallback( 287 int RegisterNewSessionCallback(
278 const NewSessionMojoCallback& callback); 288 const NewSessionMojoCallback& callback);
279 289
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 321
312 int next_request_session_id_; 322 int next_request_session_id_;
313 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; 323 base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_;
314 324
315 scoped_ptr<DefaultSessionStartContext> default_session_start_context_; 325 scoped_ptr<DefaultSessionStartContext> default_session_start_context_;
316 326
317 // RAII binding of |this| to an Presentation interface request. 327 // RAII binding of |this| to an Presentation interface request.
318 // The binding is removed when binding_ is cleared or goes out of scope. 328 // The binding is removed when binding_ is cleared or goes out of scope.
319 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_; 329 scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_;
320 330
331 scoped_ptr<SessionMessagesCallback> on_session_messages_callback_;
332
321 // ID of the RenderFrameHost this object is associated with. 333 // ID of the RenderFrameHost this object is associated with.
322 int render_process_id_; 334 int render_process_id_;
323 int render_frame_id_; 335 int render_frame_id_;
324 336
325 // NOTE: Weak pointers must be invalidated before all other member variables. 337 // NOTE: Weak pointers must be invalidated before all other member variables.
326 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; 338 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_;
327 339
328 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); 340 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl);
329 }; 341 };
330 342
331 } // namespace content 343 } // namespace content
332 344
333 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ 345 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698