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

Side by Side Diff: remoting/host/desktop_session_agent.cc

Issue 1946553002: WebRTC's scoped_ptr and scoped_ptr.h are going away, so stop using them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
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_agent.h" 5 #include "remoting/host/desktop_session_agent.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 }; 110 };
111 111
112 class SharedMemoryFactoryImpl : public webrtc::SharedMemoryFactory { 112 class SharedMemoryFactoryImpl : public webrtc::SharedMemoryFactory {
113 public: 113 public:
114 typedef base::Callback<void(std::unique_ptr<IPC::Message> message)> 114 typedef base::Callback<void(std::unique_ptr<IPC::Message> message)>
115 SendMessageCallback; 115 SendMessageCallback;
116 116
117 SharedMemoryFactoryImpl(const SendMessageCallback& send_message_callback) 117 SharedMemoryFactoryImpl(const SendMessageCallback& send_message_callback)
118 : send_message_callback_(send_message_callback) {} 118 : send_message_callback_(send_message_callback) {}
119 119
120 rtc::scoped_ptr<webrtc::SharedMemory> CreateSharedMemory( 120 std::unique_ptr<webrtc::SharedMemory> CreateSharedMemory(
121 size_t size) override { 121 size_t size) override {
122 base::Closure release_buffer_callback = 122 base::Closure release_buffer_callback =
123 base::Bind(send_message_callback_, 123 base::Bind(send_message_callback_,
124 base::Passed(base::WrapUnique( 124 base::Passed(base::WrapUnique(
125 new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer( 125 new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(
126 next_shared_buffer_id_)))); 126 next_shared_buffer_id_))));
127 std::unique_ptr<SharedMemoryImpl> buffer = SharedMemoryImpl::Create( 127 std::unique_ptr<SharedMemoryImpl> buffer = SharedMemoryImpl::Create(
128 size, next_shared_buffer_id_, release_buffer_callback); 128 size, next_shared_buffer_id_, release_buffer_callback);
129 if (buffer) { 129 if (buffer) {
130 // |next_shared_buffer_id_| starts from 1 and incrementing it by 2 makes 130 // |next_shared_buffer_id_| starts from 1 and incrementing it by 2 makes
131 // sure it is always odd and therefore zero is never used as a valid 131 // sure it is always odd and therefore zero is never used as a valid
132 // buffer ID. 132 // buffer ID.
133 // 133 //
134 // It is very unlikely (though theoretically possible) to allocate the 134 // It is very unlikely (though theoretically possible) to allocate the
135 // same ID for two different buffers due to integer overflow. It should 135 // same ID for two different buffers due to integer overflow. It should
136 // take about a year of allocating 100 new buffers every second. 136 // take about a year of allocating 100 new buffers every second.
137 // Practically speaking it never happens. 137 // Practically speaking it never happens.
138 next_shared_buffer_id_ += 2; 138 next_shared_buffer_id_ += 2;
139 139
140 send_message_callback_.Run( 140 send_message_callback_.Run(
141 base::WrapUnique(new ChromotingDesktopNetworkMsg_CreateSharedBuffer( 141 base::WrapUnique(new ChromotingDesktopNetworkMsg_CreateSharedBuffer(
142 buffer->id(), buffer->shared_memory()->handle(), 142 buffer->id(), buffer->shared_memory()->handle(),
143 buffer->size()))); 143 buffer->size())));
144 } 144 }
145 145
146 return rtc::scoped_ptr<webrtc::SharedMemory>(buffer.release()); 146 return std::move(buffer);
147 } 147 }
148 148
149 private: 149 private:
150 int next_shared_buffer_id_ = 1; 150 int next_shared_buffer_id_ = 1;
151 SendMessageCallback send_message_callback_; 151 SendMessageCallback send_message_callback_;
152 152
153 DISALLOW_COPY_AND_ASSIGN(SharedMemoryFactoryImpl); 153 DISALLOW_COPY_AND_ASSIGN(SharedMemoryFactoryImpl);
154 }; 154 };
155 155
156 } // namespace 156 } // namespace
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { 308 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) {
309 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); 309 audio_capturer_ = desktop_environment_->CreateAudioCapturer();
310 audio_capture_task_runner_->PostTask( 310 audio_capture_task_runner_->PostTask(
311 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); 311 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this));
312 } 312 }
313 313
314 // Start the video capturer and mouse cursor monitor. 314 // Start the video capturer and mouse cursor monitor.
315 video_capturer_ = desktop_environment_->CreateVideoCapturer(); 315 video_capturer_ = desktop_environment_->CreateVideoCapturer();
316 video_capturer_->Start(this); 316 video_capturer_->Start(this);
317 video_capturer_->SetSharedMemoryFactory( 317 video_capturer_->SetSharedMemoryFactory(
318 rtc::scoped_ptr<webrtc::SharedMemoryFactory>(new SharedMemoryFactoryImpl( 318 std::unique_ptr<webrtc::SharedMemoryFactory>(new SharedMemoryFactoryImpl(
319 base::Bind(&DesktopSessionAgent::SendToNetwork, this)))); 319 base::Bind(&DesktopSessionAgent::SendToNetwork, this))));
320 mouse_cursor_monitor_ = desktop_environment_->CreateMouseCursorMonitor(); 320 mouse_cursor_monitor_ = desktop_environment_->CreateMouseCursorMonitor();
321 mouse_cursor_monitor_->Init(this, webrtc::MouseCursorMonitor::SHAPE_ONLY); 321 mouse_cursor_monitor_->Init(this, webrtc::MouseCursorMonitor::SHAPE_ONLY);
322 } 322 }
323 323
324 void DesktopSessionAgent::OnCaptureCompleted(webrtc::DesktopFrame* frame) { 324 void DesktopSessionAgent::OnCaptureCompleted(webrtc::DesktopFrame* frame) {
325 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 325 DCHECK(caller_task_runner_->BelongsToCurrentThread());
326 326
327 last_frame_.reset(frame); 327 last_frame_.reset(frame);
328 328
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 578 }
579 } 579 }
580 580
581 void DesktopSessionAgent::StopAudioCapturer() { 581 void DesktopSessionAgent::StopAudioCapturer() {
582 DCHECK(audio_capture_task_runner_->BelongsToCurrentThread()); 582 DCHECK(audio_capture_task_runner_->BelongsToCurrentThread());
583 583
584 audio_capturer_.reset(); 584 audio_capturer_.reset();
585 } 585 }
586 586
587 } // namespace remoting 587 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_capturer_proxy.cc ('k') | remoting/protocol/channel_socket_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698