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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 10262035: Check whether the client is connected before trying to write to channels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | no next file » | 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/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 view_->SetView(new_size, new_clip); 323 view_->SetView(new_size, new_clip);
324 324
325 if (mouse_input_filter_.get()) { 325 if (mouse_input_filter_.get()) {
326 mouse_input_filter_->set_input_size(view_->get_view_size()); 326 mouse_input_filter_->set_input_size(view_->get_view_size());
327 } 327 }
328 } 328 }
329 329
330 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { 330 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) {
331 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); 331 DCHECK(plugin_message_loop_->BelongsToCurrentThread());
332 332
333 if (!input_handler_.get()) 333 if (!IsConnected())
334 return false; 334 return false;
335 335
336 // TODO(wez): When we have a good hook into Host dimensions changes, move 336 // TODO(wez): When we have a good hook into Host dimensions changes, move
337 // this there. 337 // this there.
338 // If |input_handler_| is valid, then |mouse_input_filter_| must also be 338 // If |input_handler_| is valid, then |mouse_input_filter_| must also be
339 // since they are constructed together as part of the input pipeline 339 // since they are constructed together as part of the input pipeline
340 mouse_input_filter_->set_output_size(view_->get_screen_size()); 340 mouse_input_filter_->set_output_size(view_->get_screen_size());
341 341
342 return input_handler_->HandleInputEvent(event); 342 return input_handler_->HandleInputEvent(event);
343 } 343 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 host_connection_.reset(); 445 host_connection_.reset();
446 446
447 SetConnectionState(STATE_CLOSED, ERROR_NONE); 447 SetConnectionState(STATE_CLOSED, ERROR_NONE);
448 } 448 }
449 449
450 void ChromotingInstance::OnIncomingIq(const std::string& iq) { 450 void ChromotingInstance::OnIncomingIq(const std::string& iq) {
451 xmpp_proxy_->OnIq(iq); 451 xmpp_proxy_->OnIq(iq);
452 } 452 }
453 453
454 void ChromotingInstance::ReleaseAllKeys() { 454 void ChromotingInstance::ReleaseAllKeys() {
455 if (input_tracker_.get()) 455 if (IsConnected())
456 input_tracker_->ReleaseAll(); 456 input_tracker_->ReleaseAll();
457 } 457 }
458 458
459 void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) { 459 void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) {
460 // Inject after the KeyEventMapper, so the event won't get mapped or trapped. 460 // Inject after the KeyEventMapper, so the event won't get mapped or trapped.
461 if (input_tracker_.get()) 461 if (IsConnected())
462 input_tracker_->InjectKeyEvent(event); 462 input_tracker_->InjectKeyEvent(event);
463 } 463 }
464 464
465 void ChromotingInstance::RemapKey(uint32 in_usb_keycode, 465 void ChromotingInstance::RemapKey(uint32 in_usb_keycode,
466 uint32 out_usb_keycode) { 466 uint32 out_usb_keycode) {
467 key_mapper_.RemapKey(in_usb_keycode, out_usb_keycode); 467 key_mapper_.RemapKey(in_usb_keycode, out_usb_keycode);
468 } 468 }
469 469
470 void ChromotingInstance::TrapKey(uint32 usb_keycode, bool trap) { 470 void ChromotingInstance::TrapKey(uint32 usb_keycode, bool trap) {
471 key_mapper_.TrapKey(usb_keycode, trap); 471 key_mapper_.TrapKey(usb_keycode, trap);
472 } 472 }
473 473
474 void ChromotingInstance::SendClipboardItem(const std::string& mime_type, 474 void ChromotingInstance::SendClipboardItem(const std::string& mime_type,
475 const std::string& item) { 475 const std::string& item) {
476 if (!host_connection_.get()) { 476 if (!IsConnected()) {
477 return; 477 return;
478 } 478 }
479 protocol::ClipboardEvent event; 479 protocol::ClipboardEvent event;
480 event.set_mime_type(mime_type); 480 event.set_mime_type(mime_type);
481 event.set_data(item); 481 event.set_data(item);
482 host_connection_->clipboard_stub()->InjectClipboardEvent(event); 482 host_connection_->clipboard_stub()->InjectClipboardEvent(event);
483 } 483 }
484 484
485 void ChromotingInstance::NotifyClientDimensions(int width, int height) { 485 void ChromotingInstance::NotifyClientDimensions(int width, int height) {
486 if (!host_connection_.get()) { 486 if (!IsConnected()) {
487 return; 487 return;
488 } 488 }
489 protocol::ClientDimensions client_dimensions; 489 protocol::ClientDimensions client_dimensions;
490 client_dimensions.set_width(width); 490 client_dimensions.set_width(width);
491 client_dimensions.set_height(height); 491 client_dimensions.set_height(height);
492 host_connection_->host_stub()->NotifyClientDimensions(client_dimensions); 492 host_connection_->host_stub()->NotifyClientDimensions(client_dimensions);
493 } 493 }
494 494
495 ChromotingStats* ChromotingInstance::GetStats() { 495 ChromotingStats* ChromotingInstance::GetStats() {
496 if (!client_.get()) 496 if (!client_.get())
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 if (scriptable_object) { 647 if (scriptable_object) {
648 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 648 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
649 data->SetString("message", message); 649 data->SetString("message", message);
650 PostChromotingMessage("logDebugMessage", data.Pass()); 650 PostChromotingMessage("logDebugMessage", data.Pass());
651 651
652 scriptable_object->LogDebugInfo(message); 652 scriptable_object->LogDebugInfo(message);
653 } 653 }
654 g_logging_to_plugin = false; 654 g_logging_to_plugin = false;
655 } 655 }
656 656
657 bool ChromotingInstance::IsConnected() {
658 return host_connection_.get() &&
659 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED);
660 }
661
657 } // namespace remoting 662 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698