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

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 1194123003: [PresentationAPI] on-session-message handler for ArrayBuffer and Blob messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wrap PresentationSessionClient in scoped_ptr. Created 5 years, 6 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 | no next file » | 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 #include "content/renderer/presentation/presentation_dispatcher.h" 5 #include "content/renderer/presentation/presentation_dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/common/presentation/presentation_service.mojom.h" 8 #include "content/common/presentation/presentation_service.mojom.h"
9 #include "content/public/common/presentation_constants.h" 9 #include "content/public/common/presentation_constants.h"
10 #include "content/public/common/service_registry.h" 10 #include "content/public/common/service_registry.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 GetWebPresentationSessionStateFromMojo(session_state)); 362 GetWebPresentationSessionStateFromMojo(session_state));
363 } 363 }
364 364
365 void PresentationDispatcher::OnSessionMessagesReceived( 365 void PresentationDispatcher::OnSessionMessagesReceived(
366 mojo::Array<presentation::SessionMessagePtr> messages) { 366 mojo::Array<presentation::SessionMessagePtr> messages) {
367 // When messages is null, there is an error at presentation service side. 367 // When messages is null, there is an error at presentation service side.
368 if (!controller_ || messages.is_null()) 368 if (!controller_ || messages.is_null())
369 return; 369 return;
370 370
371 for (size_t i = 0; i < messages.size(); ++i) { 371 for (size_t i = 0; i < messages.size(); ++i) {
372 if (messages[i]->type == 372 scoped_ptr<PresentationSessionClient> session_client(
373 presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT) { 373 new PresentationSessionClient(messages[i]->presentation_url,
mark a. foltz 2015/06/29 22:21:28 It appears that this ctor will copy the contents o
374 controller_->didReceiveSessionTextMessage( 374 messages[i]->presentation_id));
375 new PresentationSessionClient(messages[i]->presentation_url, 375 switch (messages[i]->type) {
376 messages[i]->presentation_id), 376 case presentation::PresentationMessageType::
377 blink::WebString::fromUTF8(messages[i]->message)); 377 PRESENTATION_MESSAGE_TYPE_TEXT: {
378 } else { 378 controller_->didReceiveSessionTextMessage(
379 // TODO(haibinlu): handle binary message 379 session_client.release(),
380 blink::WebString::fromUTF8(messages[i]->message));
381 break;
382 }
383 case presentation::PresentationMessageType::
384 PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER: {
385 controller_->didReceiveSessionArrayBufferMessage(
386 session_client.release(), &(messages[i]->data.front()),
387 messages[i]->data.size());
388 break;
389 }
390 case presentation::PresentationMessageType::
391 PRESENTATION_MESSAGE_TYPE_BLOB: {
392 controller_->didReceiveSessionBlobMessage(session_client.release(),
393 &(messages[i]->data.front()),
394 messages[i]->data.size());
395 break;
396 }
397 default: {
398 NOTREACHED();
399 break;
400 }
380 } 401 }
381 } 402 }
382 403
383 presentation_service_->ListenForSessionMessages( 404 presentation_service_->ListenForSessionMessages(
384 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived, 405 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived,
385 base::Unretained(this))); 406 base::Unretained(this)));
386 } 407 }
387 408
388 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { 409 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
389 if (presentation_service_.get()) 410 if (presentation_service_.get())
(...skipping 14 matching lines...) Expand all
404 presentation_service_->ListenForSessionStateChange(base::Bind( 425 presentation_service_->ListenForSessionStateChange(base::Bind(
405 &PresentationDispatcher::OnSessionStateChange, 426 &PresentationDispatcher::OnSessionStateChange,
406 base::Unretained(this))); 427 base::Unretained(this)));
407 presentation_service_->ListenForSessionMessages( 428 presentation_service_->ListenForSessionMessages(
408 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived, 429 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived,
409 base::Unretained(this))); 430 base::Unretained(this)));
410 */ 431 */
411 } 432 }
412 433
413 } // namespace content 434 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698