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 <math.h> | 7 #include <math.h> |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 base::TimeDelta timeout_duration, | 70 base::TimeDelta timeout_duration, |
71 Delegate* delegate, | 71 Delegate* delegate, |
72 const BoundNetLog& net_log) | 72 const BoundNetLog& net_log) |
73 : group_name_(group_name), | 73 : group_name_(group_name), |
74 timeout_duration_(timeout_duration), | 74 timeout_duration_(timeout_duration), |
75 delegate_(delegate), | 75 delegate_(delegate), |
76 net_log_(net_log), | 76 net_log_(net_log), |
77 idle_(true) { | 77 idle_(true) { |
78 DCHECK(!group_name.empty()); | 78 DCHECK(!group_name.empty()); |
79 DCHECK(delegate); | 79 DCHECK(delegate); |
80 net_log.BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); | 80 net_log.BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB, |
| 81 NetLog::StringCallback("group_name", &group_name_)); |
81 } | 82 } |
82 | 83 |
83 ConnectJob::~ConnectJob() { | 84 ConnectJob::~ConnectJob() { |
84 net_log().EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); | 85 net_log().EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); |
85 } | 86 } |
86 | 87 |
87 int ConnectJob::Connect() { | 88 int ConnectJob::Connect() { |
88 if (timeout_duration_ != base::TimeDelta()) | 89 if (timeout_duration_ != base::TimeDelta()) |
89 timer_.Start(FROM_HERE, timeout_duration_, this, &ConnectJob::OnTimeout); | 90 timer_.Start(FROM_HERE, timeout_duration_, this, &ConnectJob::OnTimeout); |
90 | 91 |
(...skipping 27 matching lines...) Expand all Loading... |
118 LogConnectCompletion(rv); | 119 LogConnectCompletion(rv); |
119 delegate->OnConnectJobComplete(rv, this); | 120 delegate->OnConnectJobComplete(rv, this); |
120 } | 121 } |
121 | 122 |
122 void ConnectJob::ResetTimer(base::TimeDelta remaining_time) { | 123 void ConnectJob::ResetTimer(base::TimeDelta remaining_time) { |
123 timer_.Stop(); | 124 timer_.Stop(); |
124 timer_.Start(FROM_HERE, remaining_time, this, &ConnectJob::OnTimeout); | 125 timer_.Start(FROM_HERE, remaining_time, this, &ConnectJob::OnTimeout); |
125 } | 126 } |
126 | 127 |
127 void ConnectJob::LogConnectStart() { | 128 void ConnectJob::LogConnectStart() { |
128 net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT, | 129 net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT); |
129 NetLog::StringCallback("group_name", &group_name_)); | |
130 } | 130 } |
131 | 131 |
132 void ConnectJob::LogConnectCompletion(int net_error) { | 132 void ConnectJob::LogConnectCompletion(int net_error) { |
133 net_log().EndEventWithNetErrorCode( | 133 net_log().EndEventWithNetErrorCode( |
134 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT, net_error); | 134 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT, net_error); |
135 } | 135 } |
136 | 136 |
137 void ConnectJob::OnTimeout() { | 137 void ConnectJob::OnTimeout() { |
138 // Make sure the socket is NULL before calling into |delegate|. | 138 // Make sure the socket is NULL before calling into |delegate|. |
139 set_socket(NULL); | 139 set_socket(NULL); |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 STLDeleteElements(&jobs_); | 1229 STLDeleteElements(&jobs_); |
1230 unassigned_job_count_ = 0; | 1230 unassigned_job_count_ = 0; |
1231 | 1231 |
1232 // Cancel pending backup job. | 1232 // Cancel pending backup job. |
1233 weak_factory_.InvalidateWeakPtrs(); | 1233 weak_factory_.InvalidateWeakPtrs(); |
1234 } | 1234 } |
1235 | 1235 |
1236 } // namespace internal | 1236 } // namespace internal |
1237 | 1237 |
1238 } // namespace net | 1238 } // namespace net |
OLD | NEW |