OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/desktop_session_proxy.h" | 5 #include "remoting/host/desktop_session_proxy.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 441 |
442 scoped_refptr<DesktopSessionProxy::IpcSharedBufferCore> | 442 scoped_refptr<DesktopSessionProxy::IpcSharedBufferCore> |
443 DesktopSessionProxy::GetSharedBufferCore(int id) { | 443 DesktopSessionProxy::GetSharedBufferCore(int id) { |
444 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 444 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
445 | 445 |
446 SharedBuffers::const_iterator i = shared_buffers_.find(id); | 446 SharedBuffers::const_iterator i = shared_buffers_.find(id); |
447 if (i != shared_buffers_.end()) { | 447 if (i != shared_buffers_.end()) { |
448 return i->second; | 448 return i->second; |
449 } else { | 449 } else { |
450 LOG(ERROR) << "Failed to find the shared buffer " << id; | 450 LOG(ERROR) << "Failed to find the shared buffer " << id; |
451 return NULL; | 451 return nullptr; |
452 } | 452 } |
453 } | 453 } |
454 | 454 |
455 void DesktopSessionProxy::OnAudioPacket(const std::string& serialized_packet) { | 455 void DesktopSessionProxy::OnAudioPacket(const std::string& serialized_packet) { |
456 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 456 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
457 | 457 |
458 // Parse a serialized audio packet. No further validation is done since | 458 // Parse a serialized audio packet. No further validation is done since |
459 // the message was sent by more privileged process. | 459 // the message was sent by more privileged process. |
460 scoped_ptr<AudioPacket> packet(new AudioPacket()); | 460 scoped_ptr<AudioPacket> packet(new AudioPacket()); |
461 if (!packet->ParseFromString(serialized_packet)) { | 461 if (!packet->ParseFromString(serialized_packet)) { |
462 LOG(ERROR) << "Failed to parse AudioPacket."; | 462 LOG(ERROR) << "Failed to parse AudioPacket."; |
463 return; | 463 return; |
464 } | 464 } |
465 | 465 |
466 // Pass a captured audio packet to |audio_capturer_|. | 466 // Pass a captured audio packet to |audio_capturer_|. |
467 audio_capture_task_runner_->PostTask( | 467 audio_capture_task_runner_->PostTask( |
468 FROM_HERE, base::Bind(&IpcAudioCapturer::OnAudioPacket, audio_capturer_, | 468 FROM_HERE, base::Bind(&IpcAudioCapturer::OnAudioPacket, audio_capturer_, |
469 base::Passed(&packet))); | 469 base::Passed(&packet))); |
470 } | 470 } |
471 | 471 |
472 void DesktopSessionProxy::OnCreateSharedBuffer( | 472 void DesktopSessionProxy::OnCreateSharedBuffer( |
473 int id, | 473 int id, |
474 IPC::PlatformFileForTransit handle, | 474 IPC::PlatformFileForTransit handle, |
475 uint32 size) { | 475 uint32 size) { |
476 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 476 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
477 | 477 |
478 scoped_refptr<IpcSharedBufferCore> shared_buffer = | 478 scoped_refptr<IpcSharedBufferCore> shared_buffer = |
479 new IpcSharedBufferCore(id, handle, desktop_process_, size); | 479 new IpcSharedBufferCore(id, handle, desktop_process_, size); |
480 | 480 |
481 if (shared_buffer->memory() != NULL && | 481 if (shared_buffer->memory() != nullptr && |
482 !shared_buffers_.insert(std::make_pair(id, shared_buffer)).second) { | 482 !shared_buffers_.insert(std::make_pair(id, shared_buffer)).second) { |
483 LOG(ERROR) << "Duplicate shared buffer id " << id << " encountered"; | 483 LOG(ERROR) << "Duplicate shared buffer id " << id << " encountered"; |
484 } | 484 } |
485 } | 485 } |
486 | 486 |
487 void DesktopSessionProxy::OnReleaseSharedBuffer(int id) { | 487 void DesktopSessionProxy::OnReleaseSharedBuffer(int id) { |
488 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 488 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
489 | 489 |
490 // Drop the cached reference to the buffer. | 490 // Drop the cached reference to the buffer. |
491 shared_buffers_.erase(id); | 491 shared_buffers_.erase(id); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 } | 568 } |
569 | 569 |
570 // static | 570 // static |
571 void DesktopSessionProxyTraits::Destruct( | 571 void DesktopSessionProxyTraits::Destruct( |
572 const DesktopSessionProxy* desktop_session_proxy) { | 572 const DesktopSessionProxy* desktop_session_proxy) { |
573 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, | 573 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, |
574 desktop_session_proxy); | 574 desktop_session_proxy); |
575 } | 575 } |
576 | 576 |
577 } // namespace remoting | 577 } // namespace remoting |
OLD | NEW |