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

Side by Side Diff: remoting/host/it2me/it2me_host.cc

Issue 886913002: Always run PolicyWatcher on UI thread in It2Me host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/it2me/it2me_host.h ('k') | remoting/host/policy_watcher.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/it2me/it2me_host.h" 5 #include "remoting/host/it2me/it2me_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "net/socket/client_socket_factory.h" 10 #include "net/socket/client_socket_factory.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 FROM_HERE, base::Bind(&It2MeHost::ShutdownOnUiThread, this)); 291 FROM_HERE, base::Bind(&It2MeHost::ShutdownOnUiThread, this));
292 } 292 }
293 293
294 void It2MeHost::ShutdownOnUiThread() { 294 void It2MeHost::ShutdownOnUiThread() {
295 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); 295 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread());
296 296
297 // Destroy the DesktopEnvironmentFactory, to free thread references. 297 // Destroy the DesktopEnvironmentFactory, to free thread references.
298 desktop_environment_factory_.reset(); 298 desktop_environment_factory_.reset();
299 299
300 // Stop listening for policy updates. 300 // Stop listening for policy updates.
301 if (policy_watcher_.get()) {
302 policy_watcher_->StopWatching(
303 base::Bind(&It2MeHost::OnPolicyWatcherShutdown, this));
304 return;
305 }
306 }
307
308 void It2MeHost::OnPolicyWatcherShutdown() {
309 policy_watcher_.reset(); 301 policy_watcher_.reset();
310 } 302 }
311 303
312 void It2MeHost::OnAccessDenied(const std::string& jid) { 304 void It2MeHost::OnAccessDenied(const std::string& jid) {
313 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); 305 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
314 306
315 ++failed_login_attempts_; 307 ++failed_login_attempts_;
316 if (failed_login_attempts_ == kMaxLoginAttempts) { 308 if (failed_login_attempts_ == kMaxLoginAttempts) {
317 Disconnect(); 309 Disconnect();
318 } 310 }
(...skipping 30 matching lines...) Expand all
349 SetState(kConnected); 341 SetState(kConnected);
350 } 342 }
351 343
352 void It2MeHost::OnClientDisconnected(const std::string& jid) { 344 void It2MeHost::OnClientDisconnected(const std::string& jid) {
353 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); 345 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
354 346
355 Disconnect(); 347 Disconnect();
356 } 348 }
357 349
358 void It2MeHost::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { 350 void It2MeHost::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
359 // The policy watcher runs on the |ui_task_runner| on ChromeOS and the 351 // The policy watcher runs on the |ui_task_runner|.
360 // |network_task_runner| on other platforms.
361 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { 352 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) {
362 host_context_->network_task_runner()->PostTask( 353 host_context_->network_task_runner()->PostTask(
363 FROM_HERE, 354 FROM_HERE,
364 base::Bind(&It2MeHost::OnPolicyUpdate, this, base::Passed(&policies))); 355 base::Bind(&It2MeHost::OnPolicyUpdate, this, base::Passed(&policies)));
365 return; 356 return;
366 } 357 }
367 358
368 bool nat_policy; 359 bool nat_policy;
369 if (policies->GetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, 360 if (policies->GetBoolean(policy::key::kRemoteAccessHostFirewallTraversal,
370 &nat_policy)) { 361 &nat_policy)) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 DCHECK(policy_service); 516 DCHECK(policy_service);
526 DCHECK(!policy_service_) << "|policy_service| can only be set once."; 517 DCHECK(!policy_service_) << "|policy_service| can only be set once.";
527 policy_service_ = policy_service; 518 policy_service_ = policy_service;
528 } 519 }
529 520
530 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( 521 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost(
531 scoped_ptr<ChromotingHostContext> context, 522 scoped_ptr<ChromotingHostContext> context,
532 base::WeakPtr<It2MeHost::Observer> observer, 523 base::WeakPtr<It2MeHost::Observer> observer,
533 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, 524 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
534 const std::string& directory_bot_jid) { 525 const std::string& directory_bot_jid) {
526 DCHECK(context->ui_task_runner()->BelongsToCurrentThread());
527
535 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory( 528 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory(
536 new It2MeConfirmationDialogFactory()); 529 new It2MeConfirmationDialogFactory());
537 scoped_ptr<PolicyWatcher> policy_watcher = 530 scoped_ptr<PolicyWatcher> policy_watcher =
538 PolicyWatcher::Create(policy_service_, context->network_task_runner()); 531 PolicyWatcher::Create(policy_service_, context->file_task_runner());
539 return new It2MeHost(context.Pass(), policy_watcher.Pass(), 532 return new It2MeHost(context.Pass(), policy_watcher.Pass(),
540 confirmation_dialog_factory.Pass(), 533 confirmation_dialog_factory.Pass(),
541 observer, xmpp_server_config, directory_bot_jid); 534 observer, xmpp_server_config, directory_bot_jid);
542 } 535 }
543 536
544 } // namespace remoting 537 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_host.h ('k') | remoting/host/policy_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698