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

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

Issue 10026024: Attempting to re-land a small portion of this change... Simply add links from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix willchan's nit Created 8 years, 8 months 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) 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_handle.h" 5 #include "net/socket/client_socket_handle.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/socket/client_socket_pool.h" 13 #include "net/socket/client_socket_pool.h"
14 #include "net/socket/client_socket_pool_histograms.h" 14 #include "net/socket/client_socket_pool_histograms.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 ClientSocketHandle::ClientSocketHandle() 18 ClientSocketHandle::ClientSocketHandle()
19 : is_initialized_(false), 19 : is_initialized_(false),
20 pool_(NULL),
21 layered_pool_(NULL),
20 is_reused_(false), 22 is_reused_(false),
21 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( 23 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
22 base::Bind(&ClientSocketHandle::OnIOComplete, 24 base::Bind(&ClientSocketHandle::OnIOComplete,
23 base::Unretained(this)))), 25 base::Unretained(this)))),
24 is_ssl_error_(false) {} 26 is_ssl_error_(false) {}
25 27
26 ClientSocketHandle::~ClientSocketHandle() { 28 ClientSocketHandle::~ClientSocketHandle() {
27 Reset(); 29 Reset();
28 } 30 }
29 31
(...skipping 15 matching lines...) Expand all
45 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_); 47 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_);
46 } else if (cancel) { 48 } else if (cancel) {
47 // If we did not get initialized yet, we've got a socket request pending. 49 // If we did not get initialized yet, we've got a socket request pending.
48 // Cancel it. 50 // Cancel it.
49 pool_->CancelRequest(group_name_, this); 51 pool_->CancelRequest(group_name_, this);
50 } 52 }
51 is_initialized_ = false; 53 is_initialized_ = false;
52 group_name_.clear(); 54 group_name_.clear();
53 is_reused_ = false; 55 is_reused_ = false;
54 user_callback_.Reset(); 56 user_callback_.Reset();
57 if (layered_pool_) {
58 pool_->RemoveLayeredPool(layered_pool_);
59 layered_pool_ = NULL;
60 }
55 pool_ = NULL; 61 pool_ = NULL;
56 idle_time_ = base::TimeDelta(); 62 idle_time_ = base::TimeDelta();
57 init_time_ = base::TimeTicks(); 63 init_time_ = base::TimeTicks();
58 setup_time_ = base::TimeDelta(); 64 setup_time_ = base::TimeDelta();
59 pool_id_ = -1; 65 pool_id_ = -1;
60 } 66 }
61 67
62 void ClientSocketHandle::ResetErrorState() { 68 void ClientSocketHandle::ResetErrorState() {
63 is_ssl_error_ = false; 69 is_ssl_error_ = false;
64 ssl_error_response_info_ = HttpResponseInfo(); 70 ssl_error_response_info_ = HttpResponseInfo();
65 pending_http_proxy_connection_.reset(); 71 pending_http_proxy_connection_.reset();
66 } 72 }
67 73
68 LoadState ClientSocketHandle::GetLoadState() const { 74 LoadState ClientSocketHandle::GetLoadState() const {
69 CHECK(!is_initialized()); 75 CHECK(!is_initialized());
70 CHECK(!group_name_.empty()); 76 CHECK(!group_name_.empty());
71 // Because of http://crbug.com/37810 we may not have a pool, but have 77 // Because of http://crbug.com/37810 we may not have a pool, but have
72 // just a raw socket. 78 // just a raw socket.
73 if (!pool_) 79 if (!pool_)
74 return LOAD_STATE_IDLE; 80 return LOAD_STATE_IDLE;
75 return pool_->GetLoadState(group_name_, this); 81 return pool_->GetLoadState(group_name_, this);
76 } 82 }
77 83
84 bool ClientSocketHandle::IsPoolStalled() const {
85 return pool_->IsStalled();
86 }
87
88 void ClientSocketHandle::AddLayeredPool(LayeredPool* layered_pool) {
89 CHECK(layered_pool);
90 CHECK(!layered_pool_);
91 if (pool_) {
92 pool_->AddLayeredPool(layered_pool);
93 layered_pool_ = layered_pool;
94 }
95 }
96
97 void ClientSocketHandle::RemoveLayeredPool(LayeredPool* layered_pool) {
98 CHECK(layered_pool);
99 CHECK(layered_pool_);
100 if (pool_) {
101 pool_->RemoveLayeredPool(layered_pool);
102 layered_pool_ = NULL;
103 }
104 }
105
78 void ClientSocketHandle::OnIOComplete(int result) { 106 void ClientSocketHandle::OnIOComplete(int result) {
79 CompletionCallback callback = user_callback_; 107 CompletionCallback callback = user_callback_;
80 user_callback_.Reset(); 108 user_callback_.Reset();
81 HandleInitCompletion(result); 109 HandleInitCompletion(result);
82 callback.Run(result); 110 callback.Run(result);
83 } 111 }
84 112
85 void ClientSocketHandle::HandleInitCompletion(int result) { 113 void ClientSocketHandle::HandleInitCompletion(int result) {
86 CHECK_NE(ERR_IO_PENDING, result); 114 CHECK_NE(ERR_IO_PENDING, result);
87 if (result != OK) { 115 if (result != OK) {
(...skipping 29 matching lines...) Expand all
117 // release() socket. It ends up working though, since those methods are being 145 // release() socket. It ends up working though, since those methods are being
118 // used to layer sockets (and the destination sources are the same). 146 // used to layer sockets (and the destination sources are the same).
119 DCHECK(socket_.get()); 147 DCHECK(socket_.get());
120 socket_->NetLog().BeginEvent( 148 socket_->NetLog().BeginEvent(
121 NetLog::TYPE_SOCKET_IN_USE, 149 NetLog::TYPE_SOCKET_IN_USE,
122 make_scoped_refptr(new NetLogSourceParameter( 150 make_scoped_refptr(new NetLogSourceParameter(
123 "source_dependency", requesting_source_))); 151 "source_dependency", requesting_source_)));
124 } 152 }
125 153
126 } // namespace net 154 } // 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