| OLD | NEW |
| 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/remote_input_filter.h" | 5 #include "remoting/host/remote_input_filter.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "remoting/proto/event.pb.h" | 10 #include "remoting/proto/event.pb.h" |
| 9 | 11 |
| 10 namespace { | 12 namespace { |
| 11 | 13 |
| 12 // The number of remote mouse events to record for the purpose of eliminating | 14 // The number of remote mouse events to record for the purpose of eliminating |
| 13 // "echoes" detected by the local input detector. The value should be large | 15 // "echoes" detected by the local input detector. The value should be large |
| 14 // enough to cope with the fact that multiple events might be injected before | 16 // enough to cope with the fact that multiple events might be injected before |
| 15 // any echoes are detected. | 17 // any echoes are detected. |
| 16 const unsigned int kNumRemoteMousePositions = 50; | 18 const unsigned int kNumRemoteMousePositions = 50; |
| 17 | 19 |
| 18 // The number of milliseconds for which to block remote input when local input | 20 // The number of milliseconds for which to block remote input when local input |
| 19 // is received. | 21 // is received. |
| 20 const int64 kRemoteBlockTimeoutMillis = 2000; | 22 const int64_t kRemoteBlockTimeoutMillis = 2000; |
| 21 | 23 |
| 22 } // namespace | 24 } // namespace |
| 23 | 25 |
| 24 namespace remoting { | 26 namespace remoting { |
| 25 | 27 |
| 26 RemoteInputFilter::RemoteInputFilter(protocol::InputEventTracker* event_tracker) | 28 RemoteInputFilter::RemoteInputFilter(protocol::InputEventTracker* event_tracker) |
| 27 : event_tracker_(event_tracker), | 29 : event_tracker_(event_tracker), |
| 28 expect_local_echo_(true) { | 30 expect_local_echo_(true) { |
| 29 } | 31 } |
| 30 | 32 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 98 } |
| 97 | 99 |
| 98 void RemoteInputFilter::InjectTouchEvent(const protocol::TouchEvent& event) { | 100 void RemoteInputFilter::InjectTouchEvent(const protocol::TouchEvent& event) { |
| 99 if (ShouldIgnoreInput()) | 101 if (ShouldIgnoreInput()) |
| 100 return; | 102 return; |
| 101 event_tracker_->InjectTouchEvent(event); | 103 event_tracker_->InjectTouchEvent(event); |
| 102 } | 104 } |
| 103 | 105 |
| 104 bool RemoteInputFilter::ShouldIgnoreInput() const { | 106 bool RemoteInputFilter::ShouldIgnoreInput() const { |
| 105 // Ignore remote events if the local mouse moved recently. | 107 // Ignore remote events if the local mouse moved recently. |
| 106 int64 millis = | 108 int64_t millis = |
| 107 (base::TimeTicks::Now() - latest_local_input_time_).InMilliseconds(); | 109 (base::TimeTicks::Now() - latest_local_input_time_).InMilliseconds(); |
| 108 if (millis < kRemoteBlockTimeoutMillis) | 110 if (millis < kRemoteBlockTimeoutMillis) |
| 109 return true; | 111 return true; |
| 110 return false; | 112 return false; |
| 111 } | 113 } |
| 112 | 114 |
| 113 } // namespace remoting | 115 } // namespace remoting |
| OLD | NEW |