OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // it can be deleted or reused. | 43 // it can be deleted or reused. |
44 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_); | 44 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_); |
45 } else if (cancel) { | 45 } else if (cancel) { |
46 // 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. |
47 // Cancel it. | 47 // Cancel it. |
48 pool_->CancelRequest(group_name_, this); | 48 pool_->CancelRequest(group_name_, this); |
49 } | 49 } |
50 is_initialized_ = false; | 50 is_initialized_ = false; |
51 group_name_.clear(); | 51 group_name_.clear(); |
52 is_reused_ = false; | 52 is_reused_ = false; |
53 user_callback_ = NULL; | 53 user_callback_.Reset(); |
54 if (layered_pool_) { | 54 if (layered_pool_) { |
55 pool_->RemoveLayeredPool(layered_pool_); | 55 pool_->RemoveLayeredPool(layered_pool_); |
56 layered_pool_ = NULL; | 56 layered_pool_ = NULL; |
57 } | 57 } |
58 pool_ = NULL; | 58 pool_ = NULL; |
59 idle_time_ = base::TimeDelta(); | 59 idle_time_ = base::TimeDelta(); |
60 init_time_ = base::TimeTicks(); | 60 init_time_ = base::TimeTicks(); |
61 setup_time_ = base::TimeDelta(); | 61 setup_time_ = base::TimeDelta(); |
62 pool_id_ = -1; | 62 pool_id_ = -1; |
63 } | 63 } |
(...skipping 21 matching lines...) Expand all Loading... |
85 void ClientSocketHandle::AddLayeredPool(LayeredPool* layered_pool) { | 85 void ClientSocketHandle::AddLayeredPool(LayeredPool* layered_pool) { |
86 CHECK(layered_pool); | 86 CHECK(layered_pool); |
87 CHECK(!layered_pool_); | 87 CHECK(!layered_pool_); |
88 if (pool_) { | 88 if (pool_) { |
89 pool_->AddLayeredPool(layered_pool); | 89 pool_->AddLayeredPool(layered_pool); |
90 layered_pool_ = layered_pool; | 90 layered_pool_ = layered_pool; |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 void ClientSocketHandle::OnIOComplete(int result) { | 94 void ClientSocketHandle::OnIOComplete(int result) { |
95 OldCompletionCallback* callback = user_callback_; | 95 CompletionCallback callback = user_callback_; |
96 user_callback_ = NULL; | 96 user_callback_.Reset(); |
97 HandleInitCompletion(result); | 97 HandleInitCompletion(result); |
98 callback->Run(result); | 98 callback.Run(result); |
99 } | 99 } |
100 | 100 |
101 void ClientSocketHandle::HandleInitCompletion(int result) { | 101 void ClientSocketHandle::HandleInitCompletion(int result) { |
102 CHECK_NE(ERR_IO_PENDING, result); | 102 CHECK_NE(ERR_IO_PENDING, result); |
103 if (result != OK) { | 103 if (result != OK) { |
104 if (!socket_.get()) | 104 if (!socket_.get()) |
105 ResetInternal(false); // Nothing to cancel since the request failed. | 105 ResetInternal(false); // Nothing to cancel since the request failed. |
106 else | 106 else |
107 is_initialized_ = true; | 107 is_initialized_ = true; |
108 return; | 108 return; |
(...skipping 24 matching lines...) Expand all Loading... |
133 // 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 |
134 // used to layer sockets (and the destination sources are the same). | 134 // used to layer sockets (and the destination sources are the same). |
135 DCHECK(socket_.get()); | 135 DCHECK(socket_.get()); |
136 socket_->NetLog().BeginEvent( | 136 socket_->NetLog().BeginEvent( |
137 NetLog::TYPE_SOCKET_IN_USE, | 137 NetLog::TYPE_SOCKET_IN_USE, |
138 make_scoped_refptr(new NetLogSourceParameter( | 138 make_scoped_refptr(new NetLogSourceParameter( |
139 "source_dependency", requesting_source_))); | 139 "source_dependency", requesting_source_))); |
140 } | 140 } |
141 | 141 |
142 } // namespace net | 142 } // namespace net |
OLD | NEW |