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/client_socket_pool_base.h" | 5 #include "net/socket/client_socket_pool_base.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 "base/platform_thread.h" | 9 #include "base/platform_thread.h" |
10 #include "base/scoped_vector.h" | 10 #include "base/scoped_vector.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // Socket methods: | 35 // Socket methods: |
36 virtual int Read( | 36 virtual int Read( |
37 IOBuffer* /* buf */, int /* len */, CompletionCallback* /* callback */) { | 37 IOBuffer* /* buf */, int /* len */, CompletionCallback* /* callback */) { |
38 return ERR_UNEXPECTED; | 38 return ERR_UNEXPECTED; |
39 } | 39 } |
40 | 40 |
41 virtual int Write( | 41 virtual int Write( |
42 IOBuffer* /* buf */, int /* len */, CompletionCallback* /* callback */) { | 42 IOBuffer* /* buf */, int /* len */, CompletionCallback* /* callback */) { |
43 return ERR_UNEXPECTED; | 43 return ERR_UNEXPECTED; |
44 } | 44 } |
| 45 virtual bool SetReceiveBufferSize(int32 size) { return true; }; |
| 46 virtual bool SetSendBufferSize(int32 size) { return true; }; |
45 | 47 |
46 // ClientSocket methods: | 48 // ClientSocket methods: |
47 | 49 |
48 virtual int Connect(CompletionCallback* callback) { | 50 virtual int Connect(CompletionCallback* callback) { |
49 connected_ = true; | 51 connected_ = true; |
50 return OK; | 52 return OK; |
51 } | 53 } |
52 | 54 |
53 virtual void Disconnect() { connected_ = false; } | 55 virtual void Disconnect() { connected_ = false; } |
54 virtual bool IsConnected() const { return connected_; } | 56 virtual bool IsConnected() const { return connected_; } |
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 // job. Release the socket. Run the loop again to make sure the second | 1811 // job. Release the socket. Run the loop again to make sure the second |
1810 // socket is sitting idle and the first one is released (since ReleaseSocket() | 1812 // socket is sitting idle and the first one is released (since ReleaseSocket() |
1811 // just posts a DoReleaseSocket() task). | 1813 // just posts a DoReleaseSocket() task). |
1812 | 1814 |
1813 req.handle()->Reset(); | 1815 req.handle()->Reset(); |
1814 EXPECT_EQ(OK, req2.WaitForResult()); | 1816 EXPECT_EQ(OK, req2.WaitForResult()); |
1815 req2.handle()->Reset(); | 1817 req2.handle()->Reset(); |
1816 MessageLoop::current()->RunAllPending(); | 1818 MessageLoop::current()->RunAllPending(); |
1817 | 1819 |
1818 ASSERT_EQ(2, pool_->IdleSocketCount()); | 1820 ASSERT_EQ(2, pool_->IdleSocketCount()); |
1819 | 1821 |
1820 // Invoke the idle socket cleanup check. Only one socket should be left, the | 1822 // Invoke the idle socket cleanup check. Only one socket should be left, the |
1821 // used socket. Request it to make sure that it's used. | 1823 // used socket. Request it to make sure that it's used. |
1822 | 1824 |
1823 pool_->CleanupTimedOutIdleSockets(); | 1825 pool_->CleanupTimedOutIdleSockets(); |
1824 rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), NULL); | 1826 rv = InitHandle(req.handle(), "a", 0, &req, pool_.get(), NULL); |
1825 EXPECT_EQ(OK, rv); | 1827 EXPECT_EQ(OK, rv); |
1826 EXPECT_TRUE(req.handle()->is_reused()); | 1828 EXPECT_TRUE(req.handle()->is_reused()); |
1827 } | 1829 } |
1828 | 1830 |
1829 } // namespace | 1831 } // namespace |
1830 | 1832 |
1831 } // namespace net | 1833 } // namespace net |
OLD | NEW |