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

Unified Diff: remoting/protocol/fake_session.h

Issue 8743023: Separate Authenticator and Session unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/fake_authenticator.cc ('k') | remoting/protocol/fake_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/fake_session.h
diff --git a/remoting/protocol/fake_session.h b/remoting/protocol/fake_session.h
index 90fe0c8d5d7b4fef6b7d37fc9902e6e0568e4e33..8daa59d5b0b639a82699f4f6f6a6f107a0e636c3 100644
--- a/remoting/protocol/fake_session.h
+++ b/remoting/protocol/fake_session.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h"
#include "net/socket/socket.h"
#include "net/socket/stream_socket.h"
@@ -27,6 +28,11 @@ extern const char kTestJid[];
// Read() reads data from another buffer that can be set with AppendInputData().
// Pending reads are supported, so if there is a pending read AppendInputData()
// calls the read callback.
+//
+// Two fake sockets can be connected to each other using the
+// PairWith() method, e.g.: a->PairWith(b). After this all data
+// written to |a| can be read from |b| and vica versa. Two connected
+// sockets |a| and |b| must be created and used on the same thread.
class FakeSocket : public net::StreamSocket {
public:
FakeSocket();
@@ -34,7 +40,8 @@ class FakeSocket : public net::StreamSocket {
const std::string& written_data() const { return written_data_; }
- void AppendInputData(const char* data, int data_size);
+ void AppendInputData(const std::vector<char>& data);
+ void PairWith(FakeSocket* peer_socket);
int input_pos() const { return input_pos_; }
bool read_pending() const { return read_pending_; }
@@ -47,7 +54,7 @@ class FakeSocket : public net::StreamSocket {
virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
virtual bool SetSendBufferSize(int32 size) OVERRIDE;
- // net::StreamSocket implementation.
+ // net::StreamSocket interface.
virtual int Connect(const net::CompletionCallback& callback) OVERRIDE;
virtual void Disconnect() OVERRIDE;
virtual bool IsConnected() const OVERRIDE;
@@ -67,6 +74,7 @@ class FakeSocket : public net::StreamSocket {
scoped_refptr<net::IOBuffer> read_buffer_;
int read_buffer_size_;
net::CompletionCallback read_callback_;
+ base::WeakPtr<FakeSocket> peer_socket_;
std::string written_data_;
std::string input_data_;
@@ -75,6 +83,7 @@ class FakeSocket : public net::StreamSocket {
net::BoundNetLog net_log_;
MessageLoop* message_loop_;
+ base::WeakPtrFactory<FakeSocket> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(FakeSocket);
};
« no previous file with comments | « remoting/protocol/fake_authenticator.cc ('k') | remoting/protocol/fake_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698