Chromium Code Reviews| 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 #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 Loading... | |
| 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 switch (messages[i]->type) { |
| 373 presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT) { | 373 case presentation::PresentationMessageType:: |
| 374 controller_->didReceiveSessionTextMessage( | 374 PRESENTATION_MESSAGE_TYPE_TEXT: { |
| 375 new PresentationSessionClient(messages[i]->presentation_url, | 375 controller_->didReceiveSessionTextMessage( |
| 376 messages[i]->presentation_id), | 376 new PresentationSessionClient(messages[i]->presentation_url, |
|
Habib Virji
2015/06/23 13:04:23
This can be handled prior to the switch statement
USE s.singapati at gmail.com
2015/06/23 15:06:35
Done.
| |
| 377 blink::WebString::fromUTF8(messages[i]->message)); | 377 messages[i]->presentation_id), |
| 378 } else { | 378 blink::WebString::fromUTF8(messages[i]->message)); |
| 379 // TODO(haibinlu): handle binary message | 379 break; |
| 380 } | |
| 381 case presentation::PresentationMessageType:: | |
| 382 PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER: { | |
| 383 controller_->didReceiveSessionArrayBufferMessage( | |
| 384 new PresentationSessionClient(messages[i]->presentation_url, | |
| 385 messages[i]->presentation_id), | |
| 386 &(messages[i]->data.front()), messages[i]->data.size()); | |
| 387 break; | |
| 388 } | |
| 389 case presentation::PresentationMessageType:: | |
| 390 PRESENTATION_MESSAGE_TYPE_BLOB: { | |
| 391 controller_->didReceiveSessionBlobMessage( | |
| 392 new PresentationSessionClient(messages[i]->presentation_url, | |
| 393 messages[i]->presentation_id), | |
| 394 &(messages[i]->data.front()), 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 Loading... | |
| 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 |
| OLD | NEW |