| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tcp_client_socket_pool.h" | 5 #include "net/socket/tcp_client_socket_pool.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "net/base/mock_host_resolver.h" | 9 #include "net/base/mock_host_resolver.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // Socket methods: | 45 // Socket methods: |
| 46 virtual int Read(IOBuffer* buf, int buf_len, | 46 virtual int Read(IOBuffer* buf, int buf_len, |
| 47 CompletionCallback* callback) { | 47 CompletionCallback* callback) { |
| 48 return ERR_FAILED; | 48 return ERR_FAILED; |
| 49 } | 49 } |
| 50 virtual int Write(IOBuffer* buf, int buf_len, | 50 virtual int Write(IOBuffer* buf, int buf_len, |
| 51 CompletionCallback* callback) { | 51 CompletionCallback* callback) { |
| 52 return ERR_FAILED; | 52 return ERR_FAILED; |
| 53 } | 53 } |
| 54 virtual bool SetReceiveBufferSize(int32 size) { return true; } |
| 55 virtual bool SetSendBufferSize(int32 size) { return true; } |
| 54 | 56 |
| 55 private: | 57 private: |
| 56 bool connected_; | 58 bool connected_; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 class MockFailingClientSocket : public ClientSocket { | 61 class MockFailingClientSocket : public ClientSocket { |
| 60 public: | 62 public: |
| 61 MockFailingClientSocket() {} | 63 MockFailingClientSocket() {} |
| 62 | 64 |
| 63 // ClientSocket methods: | 65 // ClientSocket methods: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 77 // Socket methods: | 79 // Socket methods: |
| 78 virtual int Read(IOBuffer* buf, int buf_len, | 80 virtual int Read(IOBuffer* buf, int buf_len, |
| 79 CompletionCallback* callback) { | 81 CompletionCallback* callback) { |
| 80 return ERR_FAILED; | 82 return ERR_FAILED; |
| 81 } | 83 } |
| 82 | 84 |
| 83 virtual int Write(IOBuffer* buf, int buf_len, | 85 virtual int Write(IOBuffer* buf, int buf_len, |
| 84 CompletionCallback* callback) { | 86 CompletionCallback* callback) { |
| 85 return ERR_FAILED; | 87 return ERR_FAILED; |
| 86 } | 88 } |
| 89 virtual bool SetReceiveBufferSize(int32 size) { return true; } |
| 90 virtual bool SetSendBufferSize(int32 size) { return true; } |
| 87 }; | 91 }; |
| 88 | 92 |
| 89 class MockPendingClientSocket : public ClientSocket { | 93 class MockPendingClientSocket : public ClientSocket { |
| 90 public: | 94 public: |
| 91 MockPendingClientSocket(bool should_connect) | 95 MockPendingClientSocket(bool should_connect) |
| 92 : method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 96 : method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 93 should_connect_(should_connect), | 97 should_connect_(should_connect), |
| 94 is_connected_(false) {} | 98 is_connected_(false) {} |
| 95 | 99 |
| 96 // ClientSocket methods: | 100 // ClientSocket methods: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 114 // Socket methods: | 118 // Socket methods: |
| 115 virtual int Read(IOBuffer* buf, int buf_len, | 119 virtual int Read(IOBuffer* buf, int buf_len, |
| 116 CompletionCallback* callback) { | 120 CompletionCallback* callback) { |
| 117 return ERR_FAILED; | 121 return ERR_FAILED; |
| 118 } | 122 } |
| 119 | 123 |
| 120 virtual int Write(IOBuffer* buf, int buf_len, | 124 virtual int Write(IOBuffer* buf, int buf_len, |
| 121 CompletionCallback* callback) { | 125 CompletionCallback* callback) { |
| 122 return ERR_FAILED; | 126 return ERR_FAILED; |
| 123 } | 127 } |
| 128 virtual bool SetReceiveBufferSize(int32 size) { return true; } |
| 129 virtual bool SetSendBufferSize(int32 size) { return true; } |
| 124 | 130 |
| 125 private: | 131 private: |
| 126 void DoCallback(CompletionCallback* callback) { | 132 void DoCallback(CompletionCallback* callback) { |
| 127 if (should_connect_) { | 133 if (should_connect_) { |
| 128 is_connected_ = true; | 134 is_connected_ = true; |
| 129 callback->Run(OK); | 135 callback->Run(OK); |
| 130 } else { | 136 } else { |
| 131 is_connected_ = false; | 137 is_connected_ = false; |
| 132 callback->Run(ERR_CONNECTION_FAILED); | 138 callback->Run(ERR_CONNECTION_FAILED); |
| 133 } | 139 } |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 for (int i = 0; i < kNumRequests; i++) | 577 for (int i = 0; i < kNumRequests; i++) |
| 572 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); | 578 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); |
| 573 | 579 |
| 574 for (int i = 0; i < kNumRequests; i++) | 580 for (int i = 0; i < kNumRequests; i++) |
| 575 EXPECT_EQ(ERR_CONNECTION_FAILED, requests_[i]->WaitForResult()); | 581 EXPECT_EQ(ERR_CONNECTION_FAILED, requests_[i]->WaitForResult()); |
| 576 } | 582 } |
| 577 | 583 |
| 578 } // namespace | 584 } // namespace |
| 579 | 585 |
| 580 } // namespace net | 586 } // namespace net |
| OLD | NEW |