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

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

Issue 569593002: Maintaining the proper order of initialization WeakPtrFactory in "src/remoting" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 years, 3 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 "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "ipc/ipc_channel_proxy.h" 10 #include "ipc/ipc_channel_proxy.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, 113 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner,
114 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 114 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
115 scoped_refptr<AutoThreadTaskRunner> input_task_runner, 115 scoped_refptr<AutoThreadTaskRunner> input_task_runner,
116 scoped_refptr<AutoThreadTaskRunner> io_task_runner, 116 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
117 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) 117 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner)
118 : audio_capture_task_runner_(audio_capture_task_runner), 118 : audio_capture_task_runner_(audio_capture_task_runner),
119 caller_task_runner_(caller_task_runner), 119 caller_task_runner_(caller_task_runner),
120 input_task_runner_(input_task_runner), 120 input_task_runner_(input_task_runner),
121 io_task_runner_(io_task_runner), 121 io_task_runner_(io_task_runner),
122 video_capture_task_runner_(video_capture_task_runner), 122 video_capture_task_runner_(video_capture_task_runner),
123 control_factory_(this),
124 next_shared_buffer_id_(1), 123 next_shared_buffer_id_(1),
125 shared_buffers_(0), 124 shared_buffers_(0),
126 started_(false) { 125 started_(false),
126 weak_factory_(this) {
127 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 127 DCHECK(caller_task_runner_->BelongsToCurrentThread());
128 } 128 }
129 129
130 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { 130 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) {
131 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 131 DCHECK(caller_task_runner_->BelongsToCurrentThread());
132 132
133 bool handled = true; 133 bool handled = true;
134 if (started_) { 134 if (started_) {
135 IPC_BEGIN_MESSAGE_MAP(DesktopSessionAgent, message) 135 IPC_BEGIN_MESSAGE_MAP(DesktopSessionAgent, message)
136 IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_CaptureFrame, 136 IPC_MESSAGE_HANDLER(ChromotingNetworkDesktopMsg_CaptureFrame,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 started_ = true; 262 started_ = true;
263 client_jid_ = authenticated_jid; 263 client_jid_ = authenticated_jid;
264 264
265 // Enable the curtain mode. 265 // Enable the curtain mode.
266 delegate_->desktop_environment_factory().SetEnableCurtaining( 266 delegate_->desktop_environment_factory().SetEnableCurtaining(
267 virtual_terminal); 267 virtual_terminal);
268 268
269 // Create a desktop environment for the new session. 269 // Create a desktop environment for the new session.
270 desktop_environment_ = delegate_->desktop_environment_factory().Create( 270 desktop_environment_ = delegate_->desktop_environment_factory().Create(
271 control_factory_.GetWeakPtr()); 271 weak_factory_.GetWeakPtr());
272 272
273 // Create the session controller and set the initial screen resolution. 273 // Create the session controller and set the initial screen resolution.
274 screen_controls_ = desktop_environment_->CreateScreenControls(); 274 screen_controls_ = desktop_environment_->CreateScreenControls();
275 SetScreenResolution(resolution); 275 SetScreenResolution(resolution);
276 276
277 // Create the input injector. 277 // Create the input injector.
278 input_injector_ = desktop_environment_->CreateInputInjector(); 278 input_injector_ = desktop_environment_->CreateInputInjector();
279 279
280 // Hook up the input filter. 280 // Hook up the input filter.
281 input_tracker_.reset(new protocol::InputEventTracker(input_injector_.get())); 281 input_tracker_.reset(new protocol::InputEventTracker(input_injector_.get()));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 delegate_.reset(); 401 delegate_.reset();
402 402
403 // Make sure the channel is closed. 403 // Make sure the channel is closed.
404 network_channel_.reset(); 404 network_channel_.reset();
405 405
406 if (started_) { 406 if (started_) {
407 started_ = false; 407 started_ = false;
408 408
409 // Ignore any further callbacks. 409 // Ignore any further callbacks.
410 control_factory_.InvalidateWeakPtrs(); 410 weak_factory_.InvalidateWeakPtrs();
411 client_jid_.clear(); 411 client_jid_.clear();
412 412
413 remote_input_filter_.reset(); 413 remote_input_filter_.reset();
414 414
415 // Ensure that any pressed keys or buttons are released. 415 // Ensure that any pressed keys or buttons are released.
416 input_tracker_->ReleaseAll(); 416 input_tracker_->ReleaseAll();
417 input_tracker_.reset(); 417 input_tracker_.reset();
418 418
419 desktop_environment_.reset(); 419 desktop_environment_.reset();
420 input_injector_.reset(); 420 input_injector_.reset();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 void DesktopSessionAgent::OnSharedBufferDeleted(int id) { 583 void DesktopSessionAgent::OnSharedBufferDeleted(int id) {
584 DCHECK(video_capture_task_runner_->BelongsToCurrentThread()); 584 DCHECK(video_capture_task_runner_->BelongsToCurrentThread());
585 DCHECK(id != 0); 585 DCHECK(id != 0);
586 586
587 shared_buffers_--; 587 shared_buffers_--;
588 DCHECK_GE(shared_buffers_, 0); 588 DCHECK_GE(shared_buffers_, 0);
589 SendToNetwork(new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(id)); 589 SendToNetwork(new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(id));
590 } 590 }
591 591
592 } // namespace remoting 592 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698