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

Side by Side Diff: net/socket/ssl_server_socket_unittest.cc

Issue 8831001: base::Bind: Convert Socket::Write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix alignment. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_server_socket_nss.cc ('k') | net/socket/tcp_client_socket_libevent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This test suite uses SSLClientSocket to test the implementation of 5 // This test suite uses SSLClientSocket to test the implementation of
6 // SSLServerSocket. In order to establish connections between the sockets 6 // SSLServerSocket. In order to establish connections between the sockets
7 // we need two additional classes: 7 // we need two additional classes:
8 // 1. FakeSocket 8 // 1. FakeSocket
9 // Connects SSL socket to FakeDataChannel. This class is just a stub. 9 // Connects SSL socket to FakeDataChannel. This class is just a stub.
10 // 10 //
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 virtual int Write(IOBuffer* buf, int buf_len, 80 virtual int Write(IOBuffer* buf, int buf_len,
81 OldCompletionCallback* callback) { 81 OldCompletionCallback* callback) {
82 data_.push(new net::DrainableIOBuffer(buf, buf_len)); 82 data_.push(new net::DrainableIOBuffer(buf, buf_len));
83 MessageLoop::current()->PostTask( 83 MessageLoop::current()->PostTask(
84 FROM_HERE, task_factory_.NewRunnableMethod( 84 FROM_HERE, task_factory_.NewRunnableMethod(
85 &FakeDataChannel::DoReadCallback)); 85 &FakeDataChannel::DoReadCallback));
86 return buf_len; 86 return buf_len;
87 } 87 }
88 virtual int Write(IOBuffer* buf, int buf_len,
89 const CompletionCallback& callback) {
90 data_.push(new net::DrainableIOBuffer(buf, buf_len));
91 MessageLoop::current()->PostTask(
92 FROM_HERE, task_factory_.NewRunnableMethod(
93 &FakeDataChannel::DoReadCallback));
94 return buf_len;
95 }
88 96
89 private: 97 private:
90 void DoReadCallback() { 98 void DoReadCallback() {
91 if ((!old_read_callback_ && read_callback_.is_null()) || data_.empty()) 99 if ((!old_read_callback_ && read_callback_.is_null()) || data_.empty())
92 return; 100 return;
93 101
94 int copied = PropogateData(read_buf_, read_buf_len_); 102 int copied = PropogateData(read_buf_, read_buf_len_);
95 if (old_read_callback_) { 103 if (old_read_callback_) {
96 net::OldCompletionCallback* callback = old_read_callback_; 104 net::OldCompletionCallback* callback = old_read_callback_;
97 old_read_callback_ = NULL; 105 old_read_callback_ = NULL;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 buf_len = rand() % buf_len + 1; 161 buf_len = rand() % buf_len + 1;
154 return incoming_->Read(buf, buf_len, callback); 162 return incoming_->Read(buf, buf_len, callback);
155 } 163 }
156 164
157 virtual int Write(IOBuffer* buf, int buf_len, 165 virtual int Write(IOBuffer* buf, int buf_len,
158 OldCompletionCallback* callback) { 166 OldCompletionCallback* callback) {
159 // Write random number of bytes. 167 // Write random number of bytes.
160 buf_len = rand() % buf_len + 1; 168 buf_len = rand() % buf_len + 1;
161 return outgoing_->Write(buf, buf_len, callback); 169 return outgoing_->Write(buf, buf_len, callback);
162 } 170 }
171 virtual int Write(IOBuffer* buf, int buf_len,
172 const CompletionCallback& callback) {
173 // Write random number of bytes.
174 buf_len = rand() % buf_len + 1;
175 return outgoing_->Write(buf, buf_len, callback);
176 }
163 177
164 virtual bool SetReceiveBufferSize(int32 size) { 178 virtual bool SetReceiveBufferSize(int32 size) {
165 return true; 179 return true;
166 } 180 }
167 181
168 virtual bool SetSendBufferSize(int32 size) { 182 virtual bool SetSendBufferSize(int32 size) {
169 return true; 183 return true;
170 } 184 }
171 185
172 virtual int Connect(OldCompletionCallback* callback) { 186 virtual int Connect(OldCompletionCallback* callback) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 const char* kKeyingLabelBad = "EXPERIMENTAL-server-socket-test-bad"; 510 const char* kKeyingLabelBad = "EXPERIMENTAL-server-socket-test-bad";
497 unsigned char client_bad[kKeyingMaterialSize]; 511 unsigned char client_bad[kKeyingMaterialSize];
498 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad, kKeyingContext, 512 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad, kKeyingContext,
499 client_bad, sizeof(client_bad)); 513 client_bad, sizeof(client_bad));
500 ASSERT_EQ(rv, net::OK); 514 ASSERT_EQ(rv, net::OK);
501 EXPECT_TRUE(memcmp(server_out, client_bad, sizeof(server_out)) != 0); 515 EXPECT_TRUE(memcmp(server_out, client_bad, sizeof(server_out)) != 0);
502 } 516 }
503 #endif 517 #endif
504 518
505 } // namespace net 519 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_server_socket_nss.cc ('k') | net/socket/tcp_client_socket_libevent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698