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 PresentationSessionClient* session_client = new PresentationSessionClient( |
|
imcheng (use chromium acct)
2015/06/23 22:08:31
Since you moved the allocation of PresentationSess
USE s.singapati at gmail.com
2015/06/25 15:34:29
Done. Used session_client.release() as it takes We
| |
| 373 presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_TEXT) { | 373 messages[i]->presentation_url, messages[i]->presentation_id); |
| 374 controller_->didReceiveSessionTextMessage( | 374 switch (messages[i]->type) { |
| 375 new PresentationSessionClient(messages[i]->presentation_url, | 375 case presentation::PresentationMessageType:: |
| 376 messages[i]->presentation_id), | 376 PRESENTATION_MESSAGE_TYPE_TEXT: { |
| 377 blink::WebString::fromUTF8(messages[i]->message)); | 377 controller_->didReceiveSessionTextMessage( |
| 378 } else { | 378 session_client, 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 session_client, &(messages[i]->data.front()), | |
| 385 messages[i]->data.size()); | |
| 386 break; | |
| 387 } | |
| 388 case presentation::PresentationMessageType:: | |
| 389 PRESENTATION_MESSAGE_TYPE_BLOB: { | |
| 390 controller_->didReceiveSessionBlobMessage(session_client, | |
| 391 &(messages[i]->data.front()), | |
| 392 messages[i]->data.size()); | |
| 393 break; | |
| 394 } | |
| 395 default: { | |
| 396 delete session_client; | |
| 397 NOTREACHED(); | |
| 398 break; | |
| 399 } | |
| 380 } | 400 } |
| 381 } | 401 } |
| 382 | 402 |
| 383 presentation_service_->ListenForSessionMessages( | 403 presentation_service_->ListenForSessionMessages( |
| 384 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived, | 404 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived, |
| 385 base::Unretained(this))); | 405 base::Unretained(this))); |
| 386 } | 406 } |
| 387 | 407 |
| 388 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { | 408 void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() { |
| 389 if (presentation_service_.get()) | 409 if (presentation_service_.get()) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 404 presentation_service_->ListenForSessionStateChange(base::Bind( | 424 presentation_service_->ListenForSessionStateChange(base::Bind( |
| 405 &PresentationDispatcher::OnSessionStateChange, | 425 &PresentationDispatcher::OnSessionStateChange, |
| 406 base::Unretained(this))); | 426 base::Unretained(this))); |
| 407 presentation_service_->ListenForSessionMessages( | 427 presentation_service_->ListenForSessionMessages( |
| 408 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived, | 428 base::Bind(&PresentationDispatcher::OnSessionMessagesReceived, |
| 409 base::Unretained(this))); | 429 base::Unretained(this))); |
| 410 */ | 430 */ |
| 411 } | 431 } |
| 412 | 432 |
| 413 } // namespace content | 433 } // namespace content |
| OLD | NEW |