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

Side by Side Diff: remoting/host/client_session.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/client_session.h" 5 #include "remoting/host/client_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "remoting/base/capabilities.h" 10 #include "remoting/base/capabilities.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 44 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
45 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 45 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
46 scoped_ptr<protocol::ConnectionToClient> connection, 46 scoped_ptr<protocol::ConnectionToClient> connection,
47 DesktopEnvironmentFactory* desktop_environment_factory, 47 DesktopEnvironmentFactory* desktop_environment_factory,
48 const base::TimeDelta& max_duration, 48 const base::TimeDelta& max_duration,
49 scoped_refptr<protocol::PairingRegistry> pairing_registry, 49 scoped_refptr<protocol::PairingRegistry> pairing_registry,
50 const std::vector<HostExtension*>& extensions) 50 const std::vector<HostExtension*>& extensions)
51 : event_handler_(event_handler), 51 : event_handler_(event_handler),
52 connection_(connection.Pass()), 52 connection_(connection.Pass()),
53 client_jid_(connection_->session()->jid()), 53 client_jid_(connection_->session()->jid()),
54 control_factory_(this),
55 desktop_environment_factory_(desktop_environment_factory), 54 desktop_environment_factory_(desktop_environment_factory),
56 input_tracker_(&host_input_filter_), 55 input_tracker_(&host_input_filter_),
57 remote_input_filter_(&input_tracker_), 56 remote_input_filter_(&input_tracker_),
58 mouse_clamping_filter_(&remote_input_filter_), 57 mouse_clamping_filter_(&remote_input_filter_),
59 disable_input_filter_(mouse_clamping_filter_.input_filter()), 58 disable_input_filter_(mouse_clamping_filter_.input_filter()),
60 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), 59 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()),
61 auth_input_filter_(&disable_input_filter_), 60 auth_input_filter_(&disable_input_filter_),
62 auth_clipboard_filter_(&disable_clipboard_filter_), 61 auth_clipboard_filter_(&disable_clipboard_filter_),
63 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), 62 client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
64 max_duration_(max_duration), 63 max_duration_(max_duration),
65 audio_task_runner_(audio_task_runner), 64 audio_task_runner_(audio_task_runner),
66 input_task_runner_(input_task_runner), 65 input_task_runner_(input_task_runner),
67 video_capture_task_runner_(video_capture_task_runner), 66 video_capture_task_runner_(video_capture_task_runner),
68 video_encode_task_runner_(video_encode_task_runner), 67 video_encode_task_runner_(video_encode_task_runner),
69 network_task_runner_(network_task_runner), 68 network_task_runner_(network_task_runner),
70 ui_task_runner_(ui_task_runner), 69 ui_task_runner_(ui_task_runner),
71 pairing_registry_(pairing_registry), 70 pairing_registry_(pairing_registry),
72 pause_video_(false), 71 pause_video_(false),
73 lossless_video_encode_(false), 72 lossless_video_encode_(false),
74 lossless_video_color_(false) { 73 lossless_video_color_(false),
74 weak_factory_(this) {
75 connection_->SetEventHandler(this); 75 connection_->SetEventHandler(this);
76 76
77 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be 77 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be
78 // set before channels are connected. Make it possible to set stubs 78 // set before channels are connected. Make it possible to set stubs
79 // later and set them only when connection is authenticated. 79 // later and set them only when connection is authenticated.
80 connection_->set_clipboard_stub(&auth_clipboard_filter_); 80 connection_->set_clipboard_stub(&auth_clipboard_filter_);
81 connection_->set_host_stub(this); 81 connection_->set_host_stub(this);
82 connection_->set_input_stub(&auth_input_filter_); 82 connection_->set_input_stub(&auth_input_filter_);
83 83
84 // |auth_*_filter_|'s states reflect whether the session is authenticated. 84 // |auth_*_filter_|'s states reflect whether the session is authenticated.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 // Disconnect the session if the connection was rejected by the host. 275 // Disconnect the session if the connection was rejected by the host.
276 if (!event_handler_->OnSessionAuthenticated(this)) { 276 if (!event_handler_->OnSessionAuthenticated(this)) {
277 DisconnectSession(); 277 DisconnectSession();
278 return; 278 return;
279 } 279 }
280 280
281 // Create the desktop environment. Drop the connection if it could not be 281 // Create the desktop environment. Drop the connection if it could not be
282 // created for any reason (for instance the curtain could not initialize). 282 // created for any reason (for instance the curtain could not initialize).
283 desktop_environment_ = 283 desktop_environment_ =
284 desktop_environment_factory_->Create(control_factory_.GetWeakPtr()); 284 desktop_environment_factory_->Create(weak_factory_.GetWeakPtr());
285 if (!desktop_environment_) { 285 if (!desktop_environment_) {
286 DisconnectSession(); 286 DisconnectSession();
287 return; 287 return;
288 } 288 }
289 289
290 // Collate the set of capabilities to offer the client, if it supports them. 290 // Collate the set of capabilities to offer the client, if it supports them.
291 if (connection_->session()->config().SupportsCapabilities()) { 291 if (connection_->session()->config().SupportsCapabilities()) {
292 host_capabilities_ = desktop_environment_->GetCapabilities(); 292 host_capabilities_ = desktop_environment_->GetCapabilities();
293 if (!host_capabilities_.empty()) { 293 if (!host_capabilities_.empty()) {
294 host_capabilities_.append(" "); 294 host_capabilities_.append(" ");
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 event_handler_->OnSessionChannelsConnected(this); 355 event_handler_->OnSessionChannelsConnected(this);
356 } 356 }
357 357
358 void ClientSession::OnConnectionClosed( 358 void ClientSession::OnConnectionClosed(
359 protocol::ConnectionToClient* connection, 359 protocol::ConnectionToClient* connection,
360 protocol::ErrorCode error) { 360 protocol::ErrorCode error) {
361 DCHECK(CalledOnValidThread()); 361 DCHECK(CalledOnValidThread());
362 DCHECK_EQ(connection_.get(), connection); 362 DCHECK_EQ(connection_.get(), connection);
363 363
364 // Ignore any further callbacks. 364 // Ignore any further callbacks.
365 control_factory_.InvalidateWeakPtrs(); 365 weak_factory_.InvalidateWeakPtrs();
366 366
367 // If the client never authenticated then the session failed. 367 // If the client never authenticated then the session failed.
368 if (!auth_input_filter_.enabled()) 368 if (!auth_input_filter_.enabled())
369 event_handler_->OnSessionAuthenticationFailed(this); 369 event_handler_->OnSessionAuthenticationFailed(this);
370 370
371 // Block any further input events from the client. 371 // Block any further input events from the client.
372 // TODO(wez): Fix ChromotingHost::OnSessionClosed not to check our 372 // TODO(wez): Fix ChromotingHost::OnSessionClosed not to check our
373 // is_authenticated(), so that we can disable |auth_*_filter_| here. 373 // is_authenticated(), so that we can disable |auth_*_filter_| here.
374 disable_input_filter_.set_enabled(false); 374 disable_input_filter_.set_enabled(false);
375 disable_clipboard_filter_.set_enabled(false); 375 disable_clipboard_filter_.set_enabled(false);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); 529 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim());
530 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { 530 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
531 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); 531 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus());
532 } 532 }
533 533
534 NOTREACHED(); 534 NOTREACHED();
535 return scoped_ptr<AudioEncoder>(); 535 return scoped_ptr<AudioEncoder>();
536 } 536 }
537 537
538 } // namespace remoting 538 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698