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

Side by Side Diff: remoting/host/plugin/host_script_object.cc

Issue 8495024: Access ChromotingHost::clients_ only on network thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/host_status_observer.h ('k') | remoting/host/screen_recorder.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/plugin/host_script_object.h" 5 #include "remoting/host/plugin/host_script_object.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 void HostNPScriptObject::OnAccessDenied() { 345 void HostNPScriptObject::OnAccessDenied() {
346 DCHECK(host_context_.network_message_loop()->BelongsToCurrentThread()); 346 DCHECK(host_context_.network_message_loop()->BelongsToCurrentThread());
347 347
348 ++failed_login_attempts_; 348 ++failed_login_attempts_;
349 if (failed_login_attempts_ == kMaxLoginAttempts) 349 if (failed_login_attempts_ == kMaxLoginAttempts)
350 DisconnectInternal(); 350 DisconnectInternal();
351 } 351 }
352 352
353 void HostNPScriptObject::OnClientAuthenticated(const std::string& jid) { 353 void HostNPScriptObject::OnClientAuthenticated(const std::string& jid) {
354 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); 354 if (MessageLoop::current() != host_context_.main_message_loop()) {
355 host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
356 &HostNPScriptObject::OnClientAuthenticated,
357 base::Unretained(this), jid));
358 return;
359 }
355 360
356 if (state_ == kDisconnecting) { 361 if (state_ == kDisconnecting) {
357 // Ignore the new connection if we are disconnecting. 362 // Ignore the new connection if we are disconnecting.
358 return; 363 return;
359 } 364 }
360 365
361 client_username_ = jid; 366 client_username_ = jid;
362 size_t pos = client_username_.find('/'); 367 size_t pos = client_username_.find('/');
363 if (pos != std::string::npos) 368 if (pos != std::string::npos)
364 client_username_.replace(pos, std::string::npos, ""); 369 client_username_.replace(pos, std::string::npos, "");
365 LOG(INFO) << "Client " << client_username_ << " connected."; 370 LOG(INFO) << "Client " << client_username_ << " connected.";
366 SetState(kConnected); 371 SetState(kConnected);
367 } 372 }
368 373
369 void HostNPScriptObject::OnClientDisconnected(const std::string& jid) { 374 void HostNPScriptObject::OnClientDisconnected(const std::string& jid) {
370 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); 375 if (MessageLoop::current() != host_context_.main_message_loop()) {
376 host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
377 &HostNPScriptObject::OnClientDisconnected,
378 base::Unretained(this), jid));
379 return;
380 }
371 381
372 client_username_.clear(); 382 client_username_.clear();
373 383
374 // Disconnect the host when a client disconnects. 384 // Disconnect the host when a client disconnects.
375 DisconnectInternal(); 385 DisconnectInternal();
376 } 386 }
377 387
378 void HostNPScriptObject::OnShutdown() { 388 void HostNPScriptObject::OnShutdown() {
379 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); 389 if (MessageLoop::current() != host_context_.main_message_loop()) {
390 host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
391 &HostNPScriptObject::OnShutdown, base::Unretained(this)));
392 return;
393 }
380 394
381 host_ = NULL; 395 host_ = NULL;
382 if (state_ != kDisconnected) { 396 if (state_ != kDisconnected) {
383 SetState(kDisconnected); 397 SetState(kDisconnected);
384 } 398 }
385 } 399 }
386 400
387 // string uid, string auth_token 401 // string uid, string auth_token
388 bool HostNPScriptObject::Connect(const NPVariant* args, 402 bool HostNPScriptObject::Connect(const NPVariant* args,
389 uint32_t arg_count, 403 uint32_t arg_count,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 default: 591 default:
578 DCHECK(host_); 592 DCHECK(host_);
579 SetState(kDisconnecting); 593 SetState(kDisconnecting);
580 host_->Shutdown( 594 host_->Shutdown(
581 base::Bind(&HostNPScriptObject::OnShutdownFinished, 595 base::Bind(&HostNPScriptObject::OnShutdownFinished,
582 base::Unretained(this))); 596 base::Unretained(this)));
583 } 597 }
584 } 598 }
585 599
586 void HostNPScriptObject::OnShutdownFinished() { 600 void HostNPScriptObject::OnShutdownFinished() {
587 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); 601 if (MessageLoop::current() != host_context_.main_message_loop()) {
602 host_context_.main_message_loop()->PostTask(FROM_HERE, base::Bind(
603 &HostNPScriptObject::OnShutdownFinished, base::Unretained(this)));
604 return;
605 }
588 606
589 disconnected_event_.Signal(); 607 disconnected_event_.Signal();
590 } 608 }
591 609
592 void HostNPScriptObject::OnNatPolicyUpdate(bool nat_traversal_enabled) { 610 void HostNPScriptObject::OnNatPolicyUpdate(bool nat_traversal_enabled) {
593 if (MessageLoop::current() != host_context_.main_message_loop()) { 611 if (MessageLoop::current() != host_context_.main_message_loop()) {
594 host_context_.main_message_loop()->PostTask( 612 host_context_.main_message_loop()->PostTask(
595 FROM_HERE, 613 FROM_HERE,
596 base::Bind(&HostNPScriptObject::OnNatPolicyUpdate, 614 base::Bind(&HostNPScriptObject::OnNatPolicyUpdate,
597 base::Unretained(this), nat_traversal_enabled)); 615 base::Unretained(this), nat_traversal_enabled));
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 uint32_t argCount) { 838 uint32_t argCount) {
821 NPVariant np_result; 839 NPVariant np_result;
822 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args, 840 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args,
823 argCount, &np_result); 841 argCount, &np_result);
824 if (is_good) 842 if (is_good)
825 g_npnetscape_funcs->releasevariantvalue(&np_result); 843 g_npnetscape_funcs->releasevariantvalue(&np_result);
826 return is_good; 844 return is_good;
827 } 845 }
828 846
829 } // namespace remoting 847 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_status_observer.h ('k') | remoting/host/screen_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698