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

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

Issue 8801005: base::Bind: Convert Socket::Read. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. 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/http/http_proxy_client_socket.cc ('k') | net/socket/socket.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 #include "net/socket/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 friend class base::RefCounted<TestSocketParams>; 42 friend class base::RefCounted<TestSocketParams>;
43 ~TestSocketParams() {} 43 ~TestSocketParams() {}
44 }; 44 };
45 typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase; 45 typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase;
46 46
47 class MockClientSocket : public StreamSocket { 47 class MockClientSocket : public StreamSocket {
48 public: 48 public:
49 MockClientSocket() : connected_(false), was_used_to_convey_data_(false), 49 MockClientSocket() : connected_(false), was_used_to_convey_data_(false),
50 num_bytes_read_(0) {} 50 num_bytes_read_(0) {}
51 51
52 // Socket methods: 52 // Socket implementation.
53 virtual int Read( 53 virtual int Read(
54 IOBuffer* /* buf */, int len, OldCompletionCallback* /* callback */) { 54 IOBuffer* /* buf */, int len, OldCompletionCallback* /* callback */) {
55 num_bytes_read_ += len; 55 num_bytes_read_ += len;
56 return len; 56 return len;
57 } 57 }
58 virtual int Read(
59 IOBuffer* /* buf */, int len, const CompletionCallback& /* callback */) {
60 num_bytes_read_ += len;
61 return len;
62 }
58 63
59 virtual int Write( 64 virtual int Write(
60 IOBuffer* /* buf */, int len, OldCompletionCallback* /* callback */) { 65 IOBuffer* /* buf */, int len, OldCompletionCallback* /* callback */) {
61 was_used_to_convey_data_ = true; 66 was_used_to_convey_data_ = true;
62 return len; 67 return len;
63 } 68 }
64 virtual bool SetReceiveBufferSize(int32 size) { return true; } 69 virtual bool SetReceiveBufferSize(int32 size) { return true; }
65 virtual bool SetSendBufferSize(int32 size) { return true; } 70 virtual bool SetSendBufferSize(int32 size) { return true; }
66 71
67 // StreamSocket implementation. 72 // StreamSocket implementation.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 if (store_additional_error_state_) { 209 if (store_additional_error_state_) {
205 // Set all of the additional error state fields in some way. 210 // Set all of the additional error state fields in some way.
206 handle->set_is_ssl_error(true); 211 handle->set_is_ssl_error(true);
207 HttpResponseInfo info; 212 HttpResponseInfo info;
208 info.headers = new HttpResponseHeaders(""); 213 info.headers = new HttpResponseHeaders("");
209 handle->set_ssl_error_response_info(info); 214 handle->set_ssl_error_response_info(info);
210 } 215 }
211 } 216 }
212 217
213 private: 218 private:
214 // ConnectJob methods: 219 // ConnectJob implementation.
215 220
216 virtual int ConnectInternal() { 221 virtual int ConnectInternal() {
217 AddressList ignored; 222 AddressList ignored;
218 client_socket_factory_->CreateTransportClientSocket( 223 client_socket_factory_->CreateTransportClientSocket(
219 ignored, NULL, net::NetLog::Source()); 224 ignored, NULL, net::NetLog::Source());
220 set_socket(new MockClientSocket()); 225 set_socket(new MockClientSocket());
221 switch (job_type_) { 226 switch (job_type_) {
222 case kMockJob: 227 case kMockJob:
223 return DoConnect(true /* successful */, false /* sync */, 228 return DoConnect(true /* successful */, false /* sync */,
224 false /* recoverable */); 229 false /* recoverable */);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 client_socket_factory_(client_socket_factory) {} 364 client_socket_factory_(client_socket_factory) {}
360 365
361 virtual ~TestConnectJobFactory() {} 366 virtual ~TestConnectJobFactory() {}
362 367
363 void set_job_type(TestConnectJob::JobType job_type) { job_type_ = job_type; } 368 void set_job_type(TestConnectJob::JobType job_type) { job_type_ = job_type; }
364 369
365 void set_timeout_duration(base::TimeDelta timeout_duration) { 370 void set_timeout_duration(base::TimeDelta timeout_duration) {
366 timeout_duration_ = timeout_duration; 371 timeout_duration_ = timeout_duration;
367 } 372 }
368 373
369 // ConnectJobFactory methods: 374 // ConnectJobFactory implementation.
370
371 virtual ConnectJob* NewConnectJob( 375 virtual ConnectJob* NewConnectJob(
372 const std::string& group_name, 376 const std::string& group_name,
373 const TestClientSocketPoolBase::Request& request, 377 const TestClientSocketPoolBase::Request& request,
374 ConnectJob::Delegate* delegate) const { 378 ConnectJob::Delegate* delegate) const {
375 return new TestConnectJob(job_type_, 379 return new TestConnectJob(job_type_,
376 group_name, 380 group_name,
377 request, 381 request,
378 timeout_duration_, 382 timeout_duration_,
379 delegate, 383 delegate,
380 client_socket_factory_, 384 client_socket_factory_,
(...skipping 2970 matching lines...) Expand 10 before | Expand all | Expand 10 after
3351 // The hung connect job should still be there, but everything else should be 3355 // The hung connect job should still be there, but everything else should be
3352 // complete. 3356 // complete.
3353 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a")); 3357 EXPECT_EQ(1, pool_->NumConnectJobsInGroup("a"));
3354 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a")); 3358 EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
3355 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a")); 3359 EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a"));
3356 } 3360 }
3357 3361
3358 } // namespace 3362 } // namespace
3359 3363
3360 } // namespace net 3364 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket.cc ('k') | net/socket/socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698