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

Unified Diff: remoting/protocol/fake_stream_socket.cc

Issue 1197853003: Add P2PDatagramSocket and P2PStreamSocket interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/fake_stream_socket.h ('k') | remoting/protocol/jingle_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/fake_stream_socket.cc
diff --git a/remoting/protocol/fake_stream_socket.cc b/remoting/protocol/fake_stream_socket.cc
index fc7f31e52dfecaf6f35266a9992f4e6159c2b7dc..b857ca1a1546c992a994a6972f430f651c9c60e4 100644
--- a/remoting/protocol/fake_stream_socket.cc
+++ b/remoting/protocol/fake_stream_socket.cc
@@ -31,6 +31,11 @@ FakeStreamSocket::FakeStreamSocket()
FakeStreamSocket::~FakeStreamSocket() {
EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
+ if (peer_socket_) {
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(&FakeStreamSocket::AppendReadError, peer_socket_,
+ net::ERR_CONNECTION_CLOSED));
+ }
}
void FakeStreamSocket::AppendInputData(const std::string& data) {
@@ -70,7 +75,8 @@ base::WeakPtr<FakeStreamSocket> FakeStreamSocket::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
-int FakeStreamSocket::Read(net::IOBuffer* buf, int buf_len,
+int FakeStreamSocket::Read(const scoped_refptr<net::IOBuffer>& buf,
+ int buf_len,
const net::CompletionCallback& callback) {
EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
@@ -92,8 +98,9 @@ int FakeStreamSocket::Read(net::IOBuffer* buf, int buf_len,
}
}
-int FakeStreamSocket::Write(net::IOBuffer* buf, int buf_len,
- const net::CompletionCallback& callback) {
+int FakeStreamSocket::Write(const scoped_refptr<net::IOBuffer>& buf,
+ int buf_len,
+ const net::CompletionCallback& callback) {
EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
EXPECT_FALSE(write_pending_);
@@ -118,7 +125,7 @@ int FakeStreamSocket::Write(net::IOBuffer* buf, int buf_len,
}
}
-void FakeStreamSocket::DoAsyncWrite(scoped_refptr<net::IOBuffer> buf,
+void FakeStreamSocket::DoAsyncWrite(const scoped_refptr<net::IOBuffer>& buf,
int buf_len,
const net::CompletionCallback& callback) {
write_pending_ = false;
@@ -134,11 +141,12 @@ void FakeStreamSocket::DoAsyncWrite(scoped_refptr<net::IOBuffer> buf,
callback.Run(buf_len);
}
-void FakeStreamSocket::DoWrite(net::IOBuffer* buf, int buf_len) {
+void FakeStreamSocket::DoWrite(const scoped_refptr<net::IOBuffer>& buf,
+ int buf_len) {
written_data_.insert(written_data_.end(),
buf->data(), buf->data() + buf_len);
- if (peer_socket_.get()) {
+ if (peer_socket_) {
task_runner_->PostTask(
FROM_HERE,
base::Bind(&FakeStreamSocket::AppendInputData,
@@ -147,109 +155,6 @@ void FakeStreamSocket::DoWrite(net::IOBuffer* buf, int buf_len) {
}
}
-int FakeStreamSocket::SetReceiveBufferSize(int32 size) {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
- return net::ERR_NOT_IMPLEMENTED;
-}
-
-int FakeStreamSocket::SetSendBufferSize(int32 size) {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
- return net::ERR_NOT_IMPLEMENTED;
-}
-
-int FakeStreamSocket::Connect(const net::CompletionCallback& callback) {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- return net::OK;
-}
-
-void FakeStreamSocket::Disconnect() {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
-
- if (peer_socket_.get()) {
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&FakeStreamSocket::AppendReadError,
- peer_socket_,
- net::ERR_CONNECTION_CLOSED));
- }
- peer_socket_.reset();
-}
-
-bool FakeStreamSocket::IsConnected() const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- return true;
-}
-
-bool FakeStreamSocket::IsConnectedAndIdle() const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
- return false;
-}
-
-int FakeStreamSocket::GetPeerAddress(net::IPEndPoint* address) const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- net::IPAddressNumber ip(net::kIPv4AddressSize);
- *address = net::IPEndPoint(ip, 0);
- return net::OK;
-}
-
-int FakeStreamSocket::GetLocalAddress(net::IPEndPoint* address) const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
- return net::ERR_NOT_IMPLEMENTED;
-}
-
-const net::BoundNetLog& FakeStreamSocket::NetLog() const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- return net_log_;
-}
-
-void FakeStreamSocket::SetSubresourceSpeculation() {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
-}
-
-void FakeStreamSocket::SetOmniboxSpeculation() {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
-}
-
-bool FakeStreamSocket::WasEverUsed() const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
- return true;
-}
-
-bool FakeStreamSocket::UsingTCPFastOpen() const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
- return true;
-}
-
-bool FakeStreamSocket::WasNpnNegotiated() const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- return false;
-}
-
-net::NextProto FakeStreamSocket::GetNegotiatedProtocol() const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- NOTIMPLEMENTED();
- return net::kProtoUnknown;
-}
-
-bool FakeStreamSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- return false;
-}
-
-void FakeStreamSocket::GetConnectionAttempts(
- net::ConnectionAttempts* out) const {
- EXPECT_TRUE(task_runner_->BelongsToCurrentThread());
- out->clear();
-}
-
FakeStreamChannelFactory::FakeStreamChannelFactory()
: task_runner_(base::ThreadTaskRunnerHandle::Get()),
asynchronous_create_(false),
« no previous file with comments | « remoting/protocol/fake_stream_socket.h ('k') | remoting/protocol/jingle_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698