| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 // Sets whether the socket has unread data. If true, the next call to Read() | 124 // Sets whether the socket has unread data. If true, the next call to Read() |
| 125 // will return 1 byte and IsConnectedAndIdle() will return false. | 125 // will return 1 byte and IsConnectedAndIdle() will return false. |
| 126 void set_has_unread_data(bool has_unread_data) { | 126 void set_has_unread_data(bool has_unread_data) { |
| 127 has_unread_data_ = has_unread_data; | 127 has_unread_data_ = has_unread_data; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Socket implementation. | 130 // Socket implementation. |
| 131 virtual int Read( | 131 virtual int Read( |
| 132 IOBuffer* /* buf */, int len, | 132 IOBuffer* /* buf */, int len, |
| 133 const CompletionCallback& /* callback */) OVERRIDE { | 133 const CompletionCallback& /* callback */) override { |
| 134 if (has_unread_data_ && len > 0) { | 134 if (has_unread_data_ && len > 0) { |
| 135 has_unread_data_ = false; | 135 has_unread_data_ = false; |
| 136 was_used_to_convey_data_ = true; | 136 was_used_to_convey_data_ = true; |
| 137 return 1; | 137 return 1; |
| 138 } | 138 } |
| 139 return ERR_UNEXPECTED; | 139 return ERR_UNEXPECTED; |
| 140 } | 140 } |
| 141 | 141 |
| 142 virtual int Write( | 142 virtual int Write( |
| 143 IOBuffer* /* buf */, int len, | 143 IOBuffer* /* buf */, int len, |
| 144 const CompletionCallback& /* callback */) OVERRIDE { | 144 const CompletionCallback& /* callback */) override { |
| 145 was_used_to_convey_data_ = true; | 145 was_used_to_convey_data_ = true; |
| 146 return len; | 146 return len; |
| 147 } | 147 } |
| 148 virtual int SetReceiveBufferSize(int32 size) OVERRIDE { return OK; } | 148 virtual int SetReceiveBufferSize(int32 size) override { return OK; } |
| 149 virtual int SetSendBufferSize(int32 size) OVERRIDE { return OK; } | 149 virtual int SetSendBufferSize(int32 size) override { return OK; } |
| 150 | 150 |
| 151 // StreamSocket implementation. | 151 // StreamSocket implementation. |
| 152 virtual int Connect(const CompletionCallback& callback) OVERRIDE { | 152 virtual int Connect(const CompletionCallback& callback) override { |
| 153 connected_ = true; | 153 connected_ = true; |
| 154 return OK; | 154 return OK; |
| 155 } | 155 } |
| 156 | 156 |
| 157 virtual void Disconnect() OVERRIDE { connected_ = false; } | 157 virtual void Disconnect() override { connected_ = false; } |
| 158 virtual bool IsConnected() const OVERRIDE { return connected_; } | 158 virtual bool IsConnected() const override { return connected_; } |
| 159 virtual bool IsConnectedAndIdle() const OVERRIDE { | 159 virtual bool IsConnectedAndIdle() const override { |
| 160 return connected_ && !has_unread_data_; | 160 return connected_ && !has_unread_data_; |
| 161 } | 161 } |
| 162 | 162 |
| 163 virtual int GetPeerAddress(IPEndPoint* /* address */) const OVERRIDE { | 163 virtual int GetPeerAddress(IPEndPoint* /* address */) const override { |
| 164 return ERR_UNEXPECTED; | 164 return ERR_UNEXPECTED; |
| 165 } | 165 } |
| 166 | 166 |
| 167 virtual int GetLocalAddress(IPEndPoint* /* address */) const OVERRIDE { | 167 virtual int GetLocalAddress(IPEndPoint* /* address */) const override { |
| 168 return ERR_UNEXPECTED; | 168 return ERR_UNEXPECTED; |
| 169 } | 169 } |
| 170 | 170 |
| 171 virtual const BoundNetLog& NetLog() const OVERRIDE { | 171 virtual const BoundNetLog& NetLog() const override { |
| 172 return net_log_; | 172 return net_log_; |
| 173 } | 173 } |
| 174 | 174 |
| 175 virtual void SetSubresourceSpeculation() OVERRIDE {} | 175 virtual void SetSubresourceSpeculation() override {} |
| 176 virtual void SetOmniboxSpeculation() OVERRIDE {} | 176 virtual void SetOmniboxSpeculation() override {} |
| 177 virtual bool WasEverUsed() const OVERRIDE { | 177 virtual bool WasEverUsed() const override { |
| 178 return was_used_to_convey_data_; | 178 return was_used_to_convey_data_; |
| 179 } | 179 } |
| 180 virtual bool UsingTCPFastOpen() const OVERRIDE { return false; } | 180 virtual bool UsingTCPFastOpen() const override { return false; } |
| 181 virtual bool WasNpnNegotiated() const OVERRIDE { | 181 virtual bool WasNpnNegotiated() const override { |
| 182 return false; | 182 return false; |
| 183 } | 183 } |
| 184 virtual NextProto GetNegotiatedProtocol() const OVERRIDE { | 184 virtual NextProto GetNegotiatedProtocol() const override { |
| 185 return kProtoUnknown; | 185 return kProtoUnknown; |
| 186 } | 186 } |
| 187 virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE { | 187 virtual bool GetSSLInfo(SSLInfo* ssl_info) override { |
| 188 return false; | 188 return false; |
| 189 } | 189 } |
| 190 | 190 |
| 191 private: | 191 private: |
| 192 bool connected_; | 192 bool connected_; |
| 193 bool has_unread_data_; | 193 bool has_unread_data_; |
| 194 BoundNetLog net_log_; | 194 BoundNetLog net_log_; |
| 195 bool was_used_to_convey_data_; | 195 bool was_used_to_convey_data_; |
| 196 | 196 |
| 197 DISALLOW_COPY_AND_ASSIGN(MockClientSocket); | 197 DISALLOW_COPY_AND_ASSIGN(MockClientSocket); |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 class TestConnectJob; | 200 class TestConnectJob; |
| 201 | 201 |
| 202 class MockClientSocketFactory : public ClientSocketFactory { | 202 class MockClientSocketFactory : public ClientSocketFactory { |
| 203 public: | 203 public: |
| 204 MockClientSocketFactory() : allocation_count_(0) {} | 204 MockClientSocketFactory() : allocation_count_(0) {} |
| 205 | 205 |
| 206 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( | 206 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
| 207 DatagramSocket::BindType bind_type, | 207 DatagramSocket::BindType bind_type, |
| 208 const RandIntCallback& rand_int_cb, | 208 const RandIntCallback& rand_int_cb, |
| 209 NetLog* net_log, | 209 NetLog* net_log, |
| 210 const NetLog::Source& source) OVERRIDE { | 210 const NetLog::Source& source) override { |
| 211 NOTREACHED(); | 211 NOTREACHED(); |
| 212 return scoped_ptr<DatagramClientSocket>(); | 212 return scoped_ptr<DatagramClientSocket>(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 virtual scoped_ptr<StreamSocket> CreateTransportClientSocket( | 215 virtual scoped_ptr<StreamSocket> CreateTransportClientSocket( |
| 216 const AddressList& addresses, | 216 const AddressList& addresses, |
| 217 NetLog* /* net_log */, | 217 NetLog* /* net_log */, |
| 218 const NetLog::Source& /*source*/) OVERRIDE { | 218 const NetLog::Source& /*source*/) override { |
| 219 allocation_count_++; | 219 allocation_count_++; |
| 220 return scoped_ptr<StreamSocket>(); | 220 return scoped_ptr<StreamSocket>(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 virtual scoped_ptr<SSLClientSocket> CreateSSLClientSocket( | 223 virtual scoped_ptr<SSLClientSocket> CreateSSLClientSocket( |
| 224 scoped_ptr<ClientSocketHandle> transport_socket, | 224 scoped_ptr<ClientSocketHandle> transport_socket, |
| 225 const HostPortPair& host_and_port, | 225 const HostPortPair& host_and_port, |
| 226 const SSLConfig& ssl_config, | 226 const SSLConfig& ssl_config, |
| 227 const SSLClientSocketContext& context) OVERRIDE { | 227 const SSLClientSocketContext& context) override { |
| 228 NOTIMPLEMENTED(); | 228 NOTIMPLEMENTED(); |
| 229 return scoped_ptr<SSLClientSocket>(); | 229 return scoped_ptr<SSLClientSocket>(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 virtual void ClearSSLSessionCache() OVERRIDE { | 232 virtual void ClearSSLSessionCache() override { |
| 233 NOTIMPLEMENTED(); | 233 NOTIMPLEMENTED(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void WaitForSignal(TestConnectJob* job) { waiting_jobs_.push_back(job); } | 236 void WaitForSignal(TestConnectJob* job) { waiting_jobs_.push_back(job); } |
| 237 | 237 |
| 238 void SignalJobs(); | 238 void SignalJobs(); |
| 239 | 239 |
| 240 void SignalJob(size_t job); | 240 void SignalJob(size_t job); |
| 241 | 241 |
| 242 void SetJobLoadState(size_t job, LoadState load_state); | 242 void SetJobLoadState(size_t job, LoadState load_state); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 void Signal() { | 286 void Signal() { |
| 287 DoConnect(waiting_success_, true /* async */, false /* recoverable */); | 287 DoConnect(waiting_success_, true /* async */, false /* recoverable */); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void set_load_state(LoadState load_state) { load_state_ = load_state; } | 290 void set_load_state(LoadState load_state) { load_state_ = load_state; } |
| 291 | 291 |
| 292 // From ConnectJob: | 292 // From ConnectJob: |
| 293 | 293 |
| 294 virtual LoadState GetLoadState() const OVERRIDE { return load_state_; } | 294 virtual LoadState GetLoadState() const override { return load_state_; } |
| 295 | 295 |
| 296 virtual void GetAdditionalErrorState(ClientSocketHandle* handle) OVERRIDE { | 296 virtual void GetAdditionalErrorState(ClientSocketHandle* handle) override { |
| 297 if (store_additional_error_state_) { | 297 if (store_additional_error_state_) { |
| 298 // Set all of the additional error state fields in some way. | 298 // Set all of the additional error state fields in some way. |
| 299 handle->set_is_ssl_error(true); | 299 handle->set_is_ssl_error(true); |
| 300 HttpResponseInfo info; | 300 HttpResponseInfo info; |
| 301 info.headers = new HttpResponseHeaders(std::string()); | 301 info.headers = new HttpResponseHeaders(std::string()); |
| 302 handle->set_ssl_error_response_info(info); | 302 handle->set_ssl_error_response_info(info); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 private: | 306 private: |
| 307 // From ConnectJob: | 307 // From ConnectJob: |
| 308 | 308 |
| 309 virtual int ConnectInternal() OVERRIDE { | 309 virtual int ConnectInternal() override { |
| 310 AddressList ignored; | 310 AddressList ignored; |
| 311 client_socket_factory_->CreateTransportClientSocket( | 311 client_socket_factory_->CreateTransportClientSocket( |
| 312 ignored, NULL, net::NetLog::Source()); | 312 ignored, NULL, net::NetLog::Source()); |
| 313 SetSocket( | 313 SetSocket( |
| 314 scoped_ptr<StreamSocket>(new MockClientSocket(net_log().net_log()))); | 314 scoped_ptr<StreamSocket>(new MockClientSocket(net_log().net_log()))); |
| 315 switch (job_type_) { | 315 switch (job_type_) { |
| 316 case kMockJob: | 316 case kMockJob: |
| 317 return DoConnect(true /* successful */, false /* sync */, | 317 return DoConnect(true /* successful */, false /* sync */, |
| 318 false /* recoverable */); | 318 false /* recoverable */); |
| 319 case kMockFailingJob: | 319 case kMockFailingJob: |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 450 |
| 451 void set_timeout_duration(base::TimeDelta timeout_duration) { | 451 void set_timeout_duration(base::TimeDelta timeout_duration) { |
| 452 timeout_duration_ = timeout_duration; | 452 timeout_duration_ = timeout_duration; |
| 453 } | 453 } |
| 454 | 454 |
| 455 // ConnectJobFactory implementation. | 455 // ConnectJobFactory implementation. |
| 456 | 456 |
| 457 virtual scoped_ptr<ConnectJob> NewConnectJob( | 457 virtual scoped_ptr<ConnectJob> NewConnectJob( |
| 458 const std::string& group_name, | 458 const std::string& group_name, |
| 459 const TestClientSocketPoolBase::Request& request, | 459 const TestClientSocketPoolBase::Request& request, |
| 460 ConnectJob::Delegate* delegate) const OVERRIDE { | 460 ConnectJob::Delegate* delegate) const override { |
| 461 EXPECT_TRUE(!job_types_ || !job_types_->empty()); | 461 EXPECT_TRUE(!job_types_ || !job_types_->empty()); |
| 462 TestConnectJob::JobType job_type = job_type_; | 462 TestConnectJob::JobType job_type = job_type_; |
| 463 if (job_types_ && !job_types_->empty()) { | 463 if (job_types_ && !job_types_->empty()) { |
| 464 job_type = job_types_->front(); | 464 job_type = job_types_->front(); |
| 465 job_types_->pop_front(); | 465 job_types_->pop_front(); |
| 466 } | 466 } |
| 467 return scoped_ptr<ConnectJob>(new TestConnectJob(job_type, | 467 return scoped_ptr<ConnectJob>(new TestConnectJob(job_type, |
| 468 group_name, | 468 group_name, |
| 469 request, | 469 request, |
| 470 timeout_duration_, | 470 timeout_duration_, |
| 471 delegate, | 471 delegate, |
| 472 client_socket_factory_, | 472 client_socket_factory_, |
| 473 net_log_)); | 473 net_log_)); |
| 474 } | 474 } |
| 475 | 475 |
| 476 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE { | 476 virtual base::TimeDelta ConnectionTimeout() const override { |
| 477 return timeout_duration_; | 477 return timeout_duration_; |
| 478 } | 478 } |
| 479 | 479 |
| 480 private: | 480 private: |
| 481 TestConnectJob::JobType job_type_; | 481 TestConnectJob::JobType job_type_; |
| 482 std::list<TestConnectJob::JobType>* job_types_; | 482 std::list<TestConnectJob::JobType>* job_types_; |
| 483 base::TimeDelta timeout_duration_; | 483 base::TimeDelta timeout_duration_; |
| 484 MockClientSocketFactory* const client_socket_factory_; | 484 MockClientSocketFactory* const client_socket_factory_; |
| 485 NetLog* net_log_; | 485 NetLog* net_log_; |
| 486 | 486 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 503 connect_job_factory) {} | 503 connect_job_factory) {} |
| 504 | 504 |
| 505 virtual ~TestClientSocketPool() {} | 505 virtual ~TestClientSocketPool() {} |
| 506 | 506 |
| 507 virtual int RequestSocket( | 507 virtual int RequestSocket( |
| 508 const std::string& group_name, | 508 const std::string& group_name, |
| 509 const void* params, | 509 const void* params, |
| 510 net::RequestPriority priority, | 510 net::RequestPriority priority, |
| 511 ClientSocketHandle* handle, | 511 ClientSocketHandle* handle, |
| 512 const CompletionCallback& callback, | 512 const CompletionCallback& callback, |
| 513 const BoundNetLog& net_log) OVERRIDE { | 513 const BoundNetLog& net_log) override { |
| 514 const scoped_refptr<TestSocketParams>* casted_socket_params = | 514 const scoped_refptr<TestSocketParams>* casted_socket_params = |
| 515 static_cast<const scoped_refptr<TestSocketParams>*>(params); | 515 static_cast<const scoped_refptr<TestSocketParams>*>(params); |
| 516 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 516 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
| 517 handle, callback, net_log); | 517 handle, callback, net_log); |
| 518 } | 518 } |
| 519 | 519 |
| 520 virtual void RequestSockets(const std::string& group_name, | 520 virtual void RequestSockets(const std::string& group_name, |
| 521 const void* params, | 521 const void* params, |
| 522 int num_sockets, | 522 int num_sockets, |
| 523 const BoundNetLog& net_log) OVERRIDE { | 523 const BoundNetLog& net_log) override { |
| 524 const scoped_refptr<TestSocketParams>* casted_params = | 524 const scoped_refptr<TestSocketParams>* casted_params = |
| 525 static_cast<const scoped_refptr<TestSocketParams>*>(params); | 525 static_cast<const scoped_refptr<TestSocketParams>*>(params); |
| 526 | 526 |
| 527 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); | 527 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); |
| 528 } | 528 } |
| 529 | 529 |
| 530 virtual void CancelRequest( | 530 virtual void CancelRequest( |
| 531 const std::string& group_name, | 531 const std::string& group_name, |
| 532 ClientSocketHandle* handle) OVERRIDE { | 532 ClientSocketHandle* handle) override { |
| 533 base_.CancelRequest(group_name, handle); | 533 base_.CancelRequest(group_name, handle); |
| 534 } | 534 } |
| 535 | 535 |
| 536 virtual void ReleaseSocket( | 536 virtual void ReleaseSocket( |
| 537 const std::string& group_name, | 537 const std::string& group_name, |
| 538 scoped_ptr<StreamSocket> socket, | 538 scoped_ptr<StreamSocket> socket, |
| 539 int id) OVERRIDE { | 539 int id) override { |
| 540 base_.ReleaseSocket(group_name, socket.Pass(), id); | 540 base_.ReleaseSocket(group_name, socket.Pass(), id); |
| 541 } | 541 } |
| 542 | 542 |
| 543 virtual void FlushWithError(int error) OVERRIDE { | 543 virtual void FlushWithError(int error) override { |
| 544 base_.FlushWithError(error); | 544 base_.FlushWithError(error); |
| 545 } | 545 } |
| 546 | 546 |
| 547 virtual bool IsStalled() const OVERRIDE { | 547 virtual bool IsStalled() const override { |
| 548 return base_.IsStalled(); | 548 return base_.IsStalled(); |
| 549 } | 549 } |
| 550 | 550 |
| 551 virtual void CloseIdleSockets() OVERRIDE { | 551 virtual void CloseIdleSockets() override { |
| 552 base_.CloseIdleSockets(); | 552 base_.CloseIdleSockets(); |
| 553 } | 553 } |
| 554 | 554 |
| 555 virtual int IdleSocketCount() const OVERRIDE { | 555 virtual int IdleSocketCount() const override { |
| 556 return base_.idle_socket_count(); | 556 return base_.idle_socket_count(); |
| 557 } | 557 } |
| 558 | 558 |
| 559 virtual int IdleSocketCountInGroup( | 559 virtual int IdleSocketCountInGroup( |
| 560 const std::string& group_name) const OVERRIDE { | 560 const std::string& group_name) const override { |
| 561 return base_.IdleSocketCountInGroup(group_name); | 561 return base_.IdleSocketCountInGroup(group_name); |
| 562 } | 562 } |
| 563 | 563 |
| 564 virtual LoadState GetLoadState( | 564 virtual LoadState GetLoadState( |
| 565 const std::string& group_name, | 565 const std::string& group_name, |
| 566 const ClientSocketHandle* handle) const OVERRIDE { | 566 const ClientSocketHandle* handle) const override { |
| 567 return base_.GetLoadState(group_name, handle); | 567 return base_.GetLoadState(group_name, handle); |
| 568 } | 568 } |
| 569 | 569 |
| 570 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE { | 570 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) override { |
| 571 base_.AddHigherLayeredPool(higher_pool); | 571 base_.AddHigherLayeredPool(higher_pool); |
| 572 } | 572 } |
| 573 | 573 |
| 574 virtual void RemoveHigherLayeredPool( | 574 virtual void RemoveHigherLayeredPool( |
| 575 HigherLayeredPool* higher_pool) OVERRIDE { | 575 HigherLayeredPool* higher_pool) override { |
| 576 base_.RemoveHigherLayeredPool(higher_pool); | 576 base_.RemoveHigherLayeredPool(higher_pool); |
| 577 } | 577 } |
| 578 | 578 |
| 579 virtual base::DictionaryValue* GetInfoAsValue( | 579 virtual base::DictionaryValue* GetInfoAsValue( |
| 580 const std::string& name, | 580 const std::string& name, |
| 581 const std::string& type, | 581 const std::string& type, |
| 582 bool include_nested_pools) const OVERRIDE { | 582 bool include_nested_pools) const override { |
| 583 return base_.GetInfoAsValue(name, type); | 583 return base_.GetInfoAsValue(name, type); |
| 584 } | 584 } |
| 585 | 585 |
| 586 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE { | 586 virtual base::TimeDelta ConnectionTimeout() const override { |
| 587 return base_.ConnectionTimeout(); | 587 return base_.ConnectionTimeout(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE { | 590 virtual ClientSocketPoolHistograms* histograms() const override { |
| 591 return base_.histograms(); | 591 return base_.histograms(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 const TestClientSocketPoolBase* base() const { return &base_; } | 594 const TestClientSocketPoolBase* base() const { return &base_; } |
| 595 | 595 |
| 596 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { | 596 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { |
| 597 return base_.NumUnassignedConnectJobsInGroup(group_name); | 597 return base_.NumUnassignedConnectJobsInGroup(group_name); |
| 598 } | 598 } |
| 599 | 599 |
| 600 int NumConnectJobsInGroup(const std::string& group_name) const { | 600 int NumConnectJobsInGroup(const std::string& group_name) const { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 ASSERT_LT(job, waiting_jobs_.size()); | 646 ASSERT_LT(job, waiting_jobs_.size()); |
| 647 waiting_jobs_[job]->set_load_state(load_state); | 647 waiting_jobs_[job]->set_load_state(load_state); |
| 648 } | 648 } |
| 649 | 649 |
| 650 class TestConnectJobDelegate : public ConnectJob::Delegate { | 650 class TestConnectJobDelegate : public ConnectJob::Delegate { |
| 651 public: | 651 public: |
| 652 TestConnectJobDelegate() | 652 TestConnectJobDelegate() |
| 653 : have_result_(false), waiting_for_result_(false), result_(OK) {} | 653 : have_result_(false), waiting_for_result_(false), result_(OK) {} |
| 654 virtual ~TestConnectJobDelegate() {} | 654 virtual ~TestConnectJobDelegate() {} |
| 655 | 655 |
| 656 virtual void OnConnectJobComplete(int result, ConnectJob* job) OVERRIDE { | 656 virtual void OnConnectJobComplete(int result, ConnectJob* job) override { |
| 657 result_ = result; | 657 result_ = result; |
| 658 scoped_ptr<ConnectJob> owned_job(job); | 658 scoped_ptr<ConnectJob> owned_job(job); |
| 659 scoped_ptr<StreamSocket> socket = owned_job->PassSocket(); | 659 scoped_ptr<StreamSocket> socket = owned_job->PassSocket(); |
| 660 // socket.get() should be NULL iff result != OK | 660 // socket.get() should be NULL iff result != OK |
| 661 EXPECT_EQ(socket == NULL, result != OK); | 661 EXPECT_EQ(socket == NULL, result != OK); |
| 662 have_result_ = true; | 662 have_result_ = true; |
| 663 if (waiting_for_result_) | 663 if (waiting_for_result_) |
| 664 base::MessageLoop::current()->Quit(); | 664 base::MessageLoop::current()->Quit(); |
| 665 } | 665 } |
| 666 | 666 |
| (...skipping 3453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4120 request(1)->handle()->Reset(); | 4120 request(1)->handle()->Reset(); |
| 4121 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); | 4121 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); |
| 4122 | 4122 |
| 4123 EXPECT_EQ(OK, request(2)->WaitForResult()); | 4123 EXPECT_EQ(OK, request(2)->WaitForResult()); |
| 4124 EXPECT_FALSE(request(1)->have_result()); | 4124 EXPECT_FALSE(request(1)->have_result()); |
| 4125 } | 4125 } |
| 4126 | 4126 |
| 4127 } // namespace | 4127 } // namespace |
| 4128 | 4128 |
| 4129 } // namespace net | 4129 } // namespace net |
| OLD | NEW |