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

Side by Side Diff: remoting/host/gnubby_socket.h

Issue 205493005: Do minimal processing of gnubby data. Add request timeouts and send error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 6 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_HOST_GNUBBY_SOCKET_H_
6 #define REMOTING_HOST_GNUBBY_SOCKET_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "base/timer/timer.h"
14 #include "net/socket/stream_listen_socket.h"
15
16 namespace remoting {
17
18 // Class that manages a socket used for gnubby requests.
19 class GnubbySocket : public base::NonThreadSafe {
20 public:
21 GnubbySocket(scoped_ptr<net::StreamListenSocket> socket,
22 const base::Closure& timeout_callback);
23
24 // Adds data to the current request.
25 void AddRequestData(const char* data, int data_len);
26
27 // Gets the current request data and clears it.
28 void GetAndClearRequestData(std::string* data_out);
29
30 // Returns true if the current request is complete.
31 bool IsRequestComplete() const;
32
33 // Returns true if the stated request size is larger than the allowed maximum.
34 bool IsRequestTooLarge() const;
35
36 // Sends response data to the socket.
37 void SendResponse(const std::string& data);
38
39 // Sends an SSH error code to the socket.
40 void SendSshError();
41
42 // Returns true if |socket| is the same one owned by this object.
43 bool IsSocket(net::StreamListenSocket* socket) const;
44
45 // Sets a timer for testing.
46 void SetTimerForTesting(scoped_ptr<base::Timer> timer);
47
48 private:
49 // Returns the stated request length.
50 size_t GetRequestLength() const;
51
52 // Returns the response length bytes.
53 std::string GetResponseLengthAsBytes(const std::string& response) const;
54
55 // Resets the socket activity timer.
56 void ResetTimer();
57
58 // The socket.
59 scoped_ptr<net::StreamListenSocket> socket_;
60
61 // Request data.
62 std::vector<char> request_data_;
63
64 // The activity timer.
65 scoped_ptr<base::Timer> timer_;
66
67 DISALLOW_COPY_AND_ASSIGN(GnubbySocket);
68 };
69
70 } // namespace remoting
71
72 #endif // REMOTING_HOST_GNUBBY_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698