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

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: rebase Created 5 years, 5 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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 GetWebPresentationSessionStateFromMojo(session_state)); 368 GetWebPresentationSessionStateFromMojo(session_state));
369 } 369 }
370 370
371 void PresentationDispatcher::OnSessionMessagesReceived( 371 void PresentationDispatcher::OnSessionMessagesReceived(
372 mojo::Array<presentation::SessionMessagePtr> messages) { 372 mojo::Array<presentation::SessionMessagePtr> messages) {
373 // When messages is null, there is an error at presentation service side. 373 // When messages is null, there is an error at presentation service side.
374 if (!controller_ || messages.is_null()) 374 if (!controller_ || messages.is_null())
375 return; 375 return;
376 376
377 for (size_t i = 0; i < messages.size(); ++i) { 377 for (size_t i = 0; i < messages.size(); ++i) {
378 if (messages[i]->type == 378 // Note: Passing batches of messages to the Blink layer would be more
379 presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT) { 379 // efficient.
380 controller_->didReceiveSessionTextMessage( 380 scoped_ptr<PresentationSessionClient> session_client(
381 new PresentationSessionClient(messages[i]->presentation_url, 381 new PresentationSessionClient(messages[i]->presentation_url,
382 messages[i]->presentation_id), 382 messages[i]->presentation_id));
383 blink::WebString::fromUTF8(messages[i]->message)); 383 switch (messages[i]->type) {
384 } else { 384 case presentation::PresentationMessageType::
385 // TODO(haibinlu): handle binary message 385 PRESENTATION_MESSAGE_TYPE_TEXT: {
386 controller_->didReceiveSessionTextMessage(
387 session_client.release(),
388 blink::WebString::fromUTF8(messages[i]->message));
389 break;
390 }
391 case presentation::PresentationMessageType::
392 PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER:
393 case presentation::PresentationMessageType::
394 PRESENTATION_MESSAGE_TYPE_BLOB: {
395 controller_->didReceiveSessionBinaryMessage(
396 session_client.release(), &(messages[i]->data.front()),
397 messages[i]->data.size());
398 break;
399 }
400 default: {
401 NOTREACHED();
402 break;
403 }
386 } 404 }
387 } 405 }
388 406
389 presentation_service_->ListenForSessionMessages( 407 presentation_service_->ListenForSessionMessages(
390 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived, 408 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived,
391 base::Unretained(this))); 409 base::Unretained(this)));
392 } 410 }
393 411
394 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { 412 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
395 if (presentation_service_.get()) 413 if (presentation_service_.get())
(...skipping 10 matching lines...) Expand all
406 base::Unretained(this))); 424 base::Unretained(this)));
407 425
408 // TODO(imcheng): Uncomment this once it is implemented on the browser 426 // TODO(imcheng): Uncomment this once it is implemented on the browser
409 // side. (crbug.com/459006) 427 // side. (crbug.com/459006)
410 // presentation_service_->ListenForSessionStateChange(base::Bind( 428 // presentation_service_->ListenForSessionStateChange(base::Bind(
411 // &PresentationDispatcher::OnSessionStateChange, 429 // &PresentationDispatcher::OnSessionStateChange,
412 // base::Unretained(this))); 430 // base::Unretained(this)));
413 } 431 }
414 432
415 } // namespace content 433 } // 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