Commit 67f59814 authored by wez@chromium.org's avatar wez@chromium.org

Check whether the client is connected before trying to write to channels.

BUG=125795,110212


Review URL: http://codereview.chromium.org/10262035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134814 0039d316-1c4b-4281-b951-d872f2087c98
parent 1b9dc9f8
......@@ -330,7 +330,7 @@ void ChromotingInstance::DidChangeView(const pp::Rect& position,
bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) {
DCHECK(plugin_message_loop_->BelongsToCurrentThread());
if (!input_handler_.get())
if (!IsConnected())
return false;
// TODO(wez): When we have a good hook into Host dimensions changes, move
......@@ -452,13 +452,13 @@ void ChromotingInstance::OnIncomingIq(const std::string& iq) {
}
void ChromotingInstance::ReleaseAllKeys() {
if (input_tracker_.get())
if (IsConnected())
input_tracker_->ReleaseAll();
}
void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) {
// Inject after the KeyEventMapper, so the event won't get mapped or trapped.
if (input_tracker_.get())
if (IsConnected())
input_tracker_->InjectKeyEvent(event);
}
......@@ -473,7 +473,7 @@ void ChromotingInstance::TrapKey(uint32 usb_keycode, bool trap) {
void ChromotingInstance::SendClipboardItem(const std::string& mime_type,
const std::string& item) {
if (!host_connection_.get()) {
if (!IsConnected()) {
return;
}
protocol::ClipboardEvent event;
......@@ -483,7 +483,7 @@ void ChromotingInstance::SendClipboardItem(const std::string& mime_type,
}
void ChromotingInstance::NotifyClientDimensions(int width, int height) {
if (!host_connection_.get()) {
if (!IsConnected()) {
return;
}
protocol::ClientDimensions client_dimensions;
......@@ -654,4 +654,9 @@ void ChromotingInstance::ProcessLogToUI(const std::string& message) {
g_logging_to_plugin = false;
}
bool ChromotingInstance::IsConnected() {
return host_connection_.get() &&
(host_connection_->state() == protocol::ConnectionToHost::CONNECTED);
}
} // namespace remoting
......@@ -190,6 +190,9 @@ class ChromotingInstance :
void ProcessLogToUI(const std::string& message);
// Returns true if there is a ConnectionToHost and it is connected.
bool IsConnected();
bool initialized_;
PepperPluginThreadDelegate plugin_thread_delegate_;
......@@ -199,6 +202,7 @@ class ChromotingInstance :
scoped_ptr<PepperView> view_;
scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_;
scoped_ptr<protocol::MouseInputFilter> mouse_input_filter_;
scoped_ptr<protocol::InputEventTracker> input_tracker_;
KeyEventMapper key_mapper_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment