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

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

Issue 8803019: Revert of 112134 of Revert 112130 - Close idle connections / SPDY sessions when needed. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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/client_socket_handle.h ('k') | net/socket/client_socket_pool.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_handle.h" 5 #include "net/socket/client_socket_handle.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "net/socket/client_socket_pool.h" 11 #include "net/socket/client_socket_pool.h"
12 #include "net/socket/client_socket_pool_histograms.h" 12 #include "net/socket/client_socket_pool_histograms.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 ClientSocketHandle::ClientSocketHandle() 16 ClientSocketHandle::ClientSocketHandle()
17 : is_initialized_(false), 17 : is_initialized_(false),
18 pool_(NULL),
19 layered_pool_(NULL),
18 is_reused_(false), 20 is_reused_(false),
19 ALLOW_THIS_IN_INITIALIZER_LIST( 21 ALLOW_THIS_IN_INITIALIZER_LIST(
20 callback_(this, &ClientSocketHandle::OnIOComplete)), 22 callback_(this, &ClientSocketHandle::OnIOComplete)),
21 is_ssl_error_(false) {} 23 is_ssl_error_(false) {}
22 24
23 ClientSocketHandle::~ClientSocketHandle() { 25 ClientSocketHandle::~ClientSocketHandle() {
24 Reset(); 26 Reset();
25 } 27 }
26 28
27 void ClientSocketHandle::Reset() { 29 void ClientSocketHandle::Reset() {
(...skipping 14 matching lines...) Expand all
42 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_); 44 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_);
43 } else if (cancel) { 45 } else if (cancel) {
44 // If we did not get initialized yet, we've got a socket request pending. 46 // If we did not get initialized yet, we've got a socket request pending.
45 // Cancel it. 47 // Cancel it.
46 pool_->CancelRequest(group_name_, this); 48 pool_->CancelRequest(group_name_, this);
47 } 49 }
48 is_initialized_ = false; 50 is_initialized_ = false;
49 group_name_.clear(); 51 group_name_.clear();
50 is_reused_ = false; 52 is_reused_ = false;
51 user_callback_ = NULL; 53 user_callback_ = NULL;
54 if (layered_pool_) {
55 pool_->RemoveLayeredPool(layered_pool_);
56 layered_pool_ = NULL;
57 }
52 pool_ = NULL; 58 pool_ = NULL;
53 idle_time_ = base::TimeDelta(); 59 idle_time_ = base::TimeDelta();
54 init_time_ = base::TimeTicks(); 60 init_time_ = base::TimeTicks();
55 setup_time_ = base::TimeDelta(); 61 setup_time_ = base::TimeDelta();
56 pool_id_ = -1; 62 pool_id_ = -1;
57 } 63 }
58 64
59 void ClientSocketHandle::ResetErrorState() { 65 void ClientSocketHandle::ResetErrorState() {
60 is_ssl_error_ = false; 66 is_ssl_error_ = false;
61 ssl_error_response_info_ = HttpResponseInfo(); 67 ssl_error_response_info_ = HttpResponseInfo();
62 pending_http_proxy_connection_.reset(); 68 pending_http_proxy_connection_.reset();
63 } 69 }
64 70
65 LoadState ClientSocketHandle::GetLoadState() const { 71 LoadState ClientSocketHandle::GetLoadState() const {
66 CHECK(!is_initialized()); 72 CHECK(!is_initialized());
67 CHECK(!group_name_.empty()); 73 CHECK(!group_name_.empty());
68 // Because of http://crbug.com/37810 we may not have a pool, but have 74 // Because of http://crbug.com/37810 we may not have a pool, but have
69 // just a raw socket. 75 // just a raw socket.
70 if (!pool_) 76 if (!pool_)
71 return LOAD_STATE_IDLE; 77 return LOAD_STATE_IDLE;
72 return pool_->GetLoadState(group_name_, this); 78 return pool_->GetLoadState(group_name_, this);
73 } 79 }
74 80
81 bool ClientSocketHandle::IsPoolStalled() const {
82 return pool_->IsStalled();
83 }
84
85 void ClientSocketHandle::AddLayeredPool(LayeredPool* layered_pool) {
86 CHECK(layered_pool);
87 CHECK(!layered_pool_);
88 if (pool_) {
89 pool_->AddLayeredPool(layered_pool);
90 layered_pool_ = layered_pool;
91 }
92 }
93
75 void ClientSocketHandle::OnIOComplete(int result) { 94 void ClientSocketHandle::OnIOComplete(int result) {
76 OldCompletionCallback* callback = user_callback_; 95 OldCompletionCallback* callback = user_callback_;
77 user_callback_ = NULL; 96 user_callback_ = NULL;
78 HandleInitCompletion(result); 97 HandleInitCompletion(result);
79 callback->Run(result); 98 callback->Run(result);
80 } 99 }
81 100
82 void ClientSocketHandle::HandleInitCompletion(int result) { 101 void ClientSocketHandle::HandleInitCompletion(int result) {
83 CHECK_NE(ERR_IO_PENDING, result); 102 CHECK_NE(ERR_IO_PENDING, result);
84 if (result != OK) { 103 if (result != OK) {
(...skipping 29 matching lines...) Expand all
114 // release() socket. It ends up working though, since those methods are being 133 // release() socket. It ends up working though, since those methods are being
115 // used to layer sockets (and the destination sources are the same). 134 // used to layer sockets (and the destination sources are the same).
116 DCHECK(socket_.get()); 135 DCHECK(socket_.get());
117 socket_->NetLog().BeginEvent( 136 socket_->NetLog().BeginEvent(
118 NetLog::TYPE_SOCKET_IN_USE, 137 NetLog::TYPE_SOCKET_IN_USE,
119 make_scoped_refptr(new NetLogSourceParameter( 138 make_scoped_refptr(new NetLogSourceParameter(
120 "source_dependency", requesting_source_))); 139 "source_dependency", requesting_source_)));
121 } 140 }
122 141
123 } // namespace net 142 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_handle.h ('k') | net/socket/client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698