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

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

Issue 8745007: Revert 112130 - Close idle connections / SPDY sessions when needed. (Closed) Base URL: svn://svn.chromium.org/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) 2011 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),
20 is_reused_(false), 18 is_reused_(false),
21 ALLOW_THIS_IN_INITIALIZER_LIST( 19 ALLOW_THIS_IN_INITIALIZER_LIST(
22 callback_(this, &ClientSocketHandle::OnIOComplete)), 20 callback_(this, &ClientSocketHandle::OnIOComplete)),
23 is_ssl_error_(false) {} 21 is_ssl_error_(false) {}
24 22
25 ClientSocketHandle::~ClientSocketHandle() { 23 ClientSocketHandle::~ClientSocketHandle() {
26 Reset(); 24 Reset();
27 } 25 }
28 26
29 void ClientSocketHandle::Reset() { 27 void ClientSocketHandle::Reset() {
(...skipping 14 matching lines...) Expand all
44 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_); 42 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_);
45 } else if (cancel) { 43 } else if (cancel) {
46 // If we did not get initialized yet, we've got a socket request pending. 44 // If we did not get initialized yet, we've got a socket request pending.
47 // Cancel it. 45 // Cancel it.
48 pool_->CancelRequest(group_name_, this); 46 pool_->CancelRequest(group_name_, this);
49 } 47 }
50 is_initialized_ = false; 48 is_initialized_ = false;
51 group_name_.clear(); 49 group_name_.clear();
52 is_reused_ = false; 50 is_reused_ = false;
53 user_callback_ = NULL; 51 user_callback_ = NULL;
54 if (layered_pool_) {
55 pool_->RemoveLayeredPool(layered_pool_);
56 layered_pool_ = NULL;
57 }
58 pool_ = NULL; 52 pool_ = NULL;
59 idle_time_ = base::TimeDelta(); 53 idle_time_ = base::TimeDelta();
60 init_time_ = base::TimeTicks(); 54 init_time_ = base::TimeTicks();
61 setup_time_ = base::TimeDelta(); 55 setup_time_ = base::TimeDelta();
62 pool_id_ = -1; 56 pool_id_ = -1;
63 } 57 }
64 58
65 void ClientSocketHandle::ResetErrorState() { 59 void ClientSocketHandle::ResetErrorState() {
66 is_ssl_error_ = false; 60 is_ssl_error_ = false;
67 ssl_error_response_info_ = HttpResponseInfo(); 61 ssl_error_response_info_ = HttpResponseInfo();
68 pending_http_proxy_connection_.reset(); 62 pending_http_proxy_connection_.reset();
69 } 63 }
70 64
71 LoadState ClientSocketHandle::GetLoadState() const { 65 LoadState ClientSocketHandle::GetLoadState() const {
72 CHECK(!is_initialized()); 66 CHECK(!is_initialized());
73 CHECK(!group_name_.empty()); 67 CHECK(!group_name_.empty());
74 // Because of http://crbug.com/37810 we may not have a pool, but have 68 // Because of http://crbug.com/37810 we may not have a pool, but have
75 // just a raw socket. 69 // just a raw socket.
76 if (!pool_) 70 if (!pool_)
77 return LOAD_STATE_IDLE; 71 return LOAD_STATE_IDLE;
78 return pool_->GetLoadState(group_name_, this); 72 return pool_->GetLoadState(group_name_, this);
79 } 73 }
80 74
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
94 void ClientSocketHandle::OnIOComplete(int result) { 75 void ClientSocketHandle::OnIOComplete(int result) {
95 OldCompletionCallback* callback = user_callback_; 76 OldCompletionCallback* callback = user_callback_;
96 user_callback_ = NULL; 77 user_callback_ = NULL;
97 HandleInitCompletion(result); 78 HandleInitCompletion(result);
98 callback->Run(result); 79 callback->Run(result);
99 } 80 }
100 81
101 void ClientSocketHandle::HandleInitCompletion(int result) { 82 void ClientSocketHandle::HandleInitCompletion(int result) {
102 CHECK_NE(ERR_IO_PENDING, result); 83 CHECK_NE(ERR_IO_PENDING, result);
103 if (result != OK) { 84 if (result != OK) {
(...skipping 29 matching lines...) Expand all
133 // release() socket. It ends up working though, since those methods are being 114 // release() socket. It ends up working though, since those methods are being
134 // used to layer sockets (and the destination sources are the same). 115 // used to layer sockets (and the destination sources are the same).
135 DCHECK(socket_.get()); 116 DCHECK(socket_.get());
136 socket_->NetLog().BeginEvent( 117 socket_->NetLog().BeginEvent(
137 NetLog::TYPE_SOCKET_IN_USE, 118 NetLog::TYPE_SOCKET_IN_USE,
138 make_scoped_refptr(new NetLogSourceParameter( 119 make_scoped_refptr(new NetLogSourceParameter(
139 "source_dependency", requesting_source_))); 120 "source_dependency", requesting_source_)));
140 } 121 }
141 122
142 } // namespace net 123 } // 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