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

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

Issue 1903663004: IPC: Fix attachment brokering race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (scoped_ptr->std::unique_ptr) Created 4 years, 8 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 | « remoting/host/desktop_process.cc ('k') | remoting/host/ipc_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/memory/shared_memory.h" 13 #include "base/memory/shared_memory.h"
14 #include "base/process/process_handle.h" 14 #include "base/process/process_handle.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "ipc/attachment_broker.h"
16 #include "ipc/ipc_channel_proxy.h" 17 #include "ipc/ipc_channel_proxy.h"
17 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
18 #include "ipc/ipc_message_macros.h" 19 #include "ipc/ipc_message_macros.h"
19 #include "remoting/base/auto_thread_task_runner.h" 20 #include "remoting/base/auto_thread_task_runner.h"
20 #include "remoting/base/constants.h" 21 #include "remoting/base/constants.h"
21 #include "remoting/host/audio_capturer.h" 22 #include "remoting/host/audio_capturer.h"
22 #include "remoting/host/chromoting_messages.h" 23 #include "remoting/host/chromoting_messages.h"
23 #include "remoting/host/desktop_environment.h" 24 #include "remoting/host/desktop_environment.h"
24 #include "remoting/host/input_injector.h" 25 #include "remoting/host/input_injector.h"
25 #include "remoting/host/ipc_util.h" 26 #include "remoting/host/ipc_util.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 209
209 VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")"; 210 VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")";
210 211
211 desktop_pipe_.Close(); 212 desktop_pipe_.Close();
212 } 213 }
213 214
214 void DesktopSessionAgent::OnChannelError() { 215 void DesktopSessionAgent::OnChannelError() {
215 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 216 DCHECK(caller_task_runner_->BelongsToCurrentThread());
216 217
217 // Make sure the channel is closed. 218 // Make sure the channel is closed.
219 if (IPC::AttachmentBroker::GetGlobal()) {
220 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
221 network_channel_.get());
222 }
218 network_channel_.reset(); 223 network_channel_.reset();
219 desktop_pipe_.Close(); 224 desktop_pipe_.Close();
220 225
221 // Notify the caller that the channel has been disconnected. 226 // Notify the caller that the channel has been disconnected.
222 if (delegate_.get()) 227 if (delegate_.get())
223 delegate_->OnNetworkProcessDisconnected(); 228 delegate_->OnNetworkProcessDisconnected();
224 } 229 }
225 230
226 DesktopSessionAgent::~DesktopSessionAgent() { 231 DesktopSessionAgent::~DesktopSessionAgent() {
227 DCHECK(!audio_capturer_); 232 DCHECK(!audio_capturer_);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 #endif 411 #endif
407 return result; 412 return result;
408 } 413 }
409 414
410 void DesktopSessionAgent::Stop() { 415 void DesktopSessionAgent::Stop() {
411 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 416 DCHECK(caller_task_runner_->BelongsToCurrentThread());
412 417
413 delegate_.reset(); 418 delegate_.reset();
414 419
415 // Make sure the channel is closed. 420 // Make sure the channel is closed.
421 if (IPC::AttachmentBroker::GetGlobal()) {
422 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
423 network_channel_.get());
424 }
416 network_channel_.reset(); 425 network_channel_.reset();
417 426
418 if (started_) { 427 if (started_) {
419 started_ = false; 428 started_ = false;
420 429
421 // Ignore any further callbacks. 430 // Ignore any further callbacks.
422 weak_factory_.InvalidateWeakPtrs(); 431 weak_factory_.InvalidateWeakPtrs();
423 client_jid_.clear(); 432 client_jid_.clear();
424 433
425 remote_input_filter_.reset(); 434 remote_input_filter_.reset();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 578 }
570 } 579 }
571 580
572 void DesktopSessionAgent::StopAudioCapturer() { 581 void DesktopSessionAgent::StopAudioCapturer() {
573 DCHECK(audio_capture_task_runner_->BelongsToCurrentThread()); 582 DCHECK(audio_capture_task_runner_->BelongsToCurrentThread());
574 583
575 audio_capturer_.reset(); 584 audio_capturer_.reset();
576 } 585 }
577 586
578 } // namespace remoting 587 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_process.cc ('k') | remoting/host/ipc_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698