| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gnubby_socket.h" | 5 #include "remoting/host/gnubby_socket.h" |
| 6 | 6 |
| 7 #include "base/macros.h" |
| 7 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 8 #include "net/socket/stream_listen_socket.h" | 9 #include "net/socket/stream_listen_socket.h" |
| 9 | 10 |
| 10 namespace remoting { | 11 namespace remoting { |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 const size_t kRequestSizeBytes = 4; | 15 const size_t kRequestSizeBytes = 4; |
| 15 const size_t kMaxRequestLength = 16384; | 16 const size_t kMaxRequestLength = 16384; |
| 16 const unsigned int kRequestTimeoutSeconds = 60; | 17 const unsigned int kRequestTimeoutSeconds = 60; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 DCHECK(CalledOnValidThread()); | 69 DCHECK(CalledOnValidThread()); |
| 69 | 70 |
| 70 socket_->Send(GetResponseLengthAsBytes(response_data)); | 71 socket_->Send(GetResponseLengthAsBytes(response_data)); |
| 71 socket_->Send(response_data); | 72 socket_->Send(response_data); |
| 72 ResetTimer(); | 73 ResetTimer(); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void GnubbySocket::SendSshError() { | 76 void GnubbySocket::SendSshError() { |
| 76 DCHECK(CalledOnValidThread()); | 77 DCHECK(CalledOnValidThread()); |
| 77 | 78 |
| 78 SendResponse(kSshError); | 79 SendResponse(std::string(kSshError, arraysize(kSshError))); |
| 79 } | 80 } |
| 80 | 81 |
| 81 bool GnubbySocket::IsSocket(net::StreamListenSocket* socket) const { | 82 bool GnubbySocket::IsSocket(net::StreamListenSocket* socket) const { |
| 82 return socket == socket_.get(); | 83 return socket == socket_.get(); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void GnubbySocket::SetTimerForTesting(scoped_ptr<base::Timer> timer) { | 86 void GnubbySocket::SetTimerForTesting(scoped_ptr<base::Timer> timer) { |
| 86 timer->Start(FROM_HERE, timer_->GetCurrentDelay(), timer_->user_task()); | 87 timer->Start(FROM_HERE, timer_->GetCurrentDelay(), timer_->user_task()); |
| 87 timer_ = timer.Pass(); | 88 timer_ = timer.Pass(); |
| 88 } | 89 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 107 | 108 |
| 108 return response_len; | 109 return response_len; |
| 109 } | 110 } |
| 110 | 111 |
| 111 void GnubbySocket::ResetTimer() { | 112 void GnubbySocket::ResetTimer() { |
| 112 if (timer_->IsRunning()) | 113 if (timer_->IsRunning()) |
| 113 timer_->Reset(); | 114 timer_->Reset(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // namespace remoting | 117 } // namespace remoting |
| OLD | NEW |