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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // after a certain timeout has passed without receiving an ACK. | 33 // after a certain timeout has passed without receiving an ACK. |
34 bool g_connect_backup_jobs_enabled = true; | 34 bool g_connect_backup_jobs_enabled = true; |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 ConnectJob::ConnectJob(const std::string& group_name, | 38 ConnectJob::ConnectJob(const std::string& group_name, |
39 base::TimeDelta timeout_duration, | 39 base::TimeDelta timeout_duration, |
40 RequestPriority priority, | 40 RequestPriority priority, |
41 ClientSocketPool::RespectLimits respect_limits, | 41 ClientSocketPool::RespectLimits respect_limits, |
42 Delegate* delegate, | 42 Delegate* delegate, |
43 const BoundNetLog& net_log) | 43 const NetLogWithSource& net_log) |
44 : group_name_(group_name), | 44 : group_name_(group_name), |
45 timeout_duration_(timeout_duration), | 45 timeout_duration_(timeout_duration), |
46 priority_(priority), | 46 priority_(priority), |
47 respect_limits_(respect_limits), | 47 respect_limits_(respect_limits), |
48 delegate_(delegate), | 48 delegate_(delegate), |
49 net_log_(net_log), | 49 net_log_(net_log), |
50 idle_(true) { | 50 idle_(true) { |
51 DCHECK(!group_name.empty()); | 51 DCHECK(!group_name.empty()); |
52 DCHECK(delegate); | 52 DCHECK(delegate); |
53 net_log.BeginEvent(NetLogEventType::SOCKET_POOL_CONNECT_JOB, | 53 net_log.BeginEvent(NetLogEventType::SOCKET_POOL_CONNECT_JOB, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 namespace internal { | 126 namespace internal { |
127 | 127 |
128 ClientSocketPoolBaseHelper::Request::Request( | 128 ClientSocketPoolBaseHelper::Request::Request( |
129 ClientSocketHandle* handle, | 129 ClientSocketHandle* handle, |
130 const CompletionCallback& callback, | 130 const CompletionCallback& callback, |
131 RequestPriority priority, | 131 RequestPriority priority, |
132 ClientSocketPool::RespectLimits respect_limits, | 132 ClientSocketPool::RespectLimits respect_limits, |
133 Flags flags, | 133 Flags flags, |
134 const BoundNetLog& net_log) | 134 const NetLogWithSource& net_log) |
135 : handle_(handle), | 135 : handle_(handle), |
136 callback_(callback), | 136 callback_(callback), |
137 priority_(priority), | 137 priority_(priority), |
138 respect_limits_(respect_limits), | 138 respect_limits_(respect_limits), |
139 flags_(flags), | 139 flags_(flags), |
140 net_log_(net_log) { | 140 net_log_(net_log) { |
141 if (respect_limits_ == ClientSocketPool::RespectLimits::DISABLED) | 141 if (respect_limits_ == ClientSocketPool::RespectLimits::DISABLED) |
142 DCHECK_EQ(priority_, MAXIMUM_PRIORITY); | 142 DCHECK_EQ(priority_, MAXIMUM_PRIORITY); |
143 } | 143 } |
144 | 144 |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 DCHECK_NE(ERR_IO_PENDING, result); | 853 DCHECK_NE(ERR_IO_PENDING, result); |
854 const std::string group_name = job->group_name(); | 854 const std::string group_name = job->group_name(); |
855 GroupMap::iterator group_it = group_map_.find(group_name); | 855 GroupMap::iterator group_it = group_map_.find(group_name); |
856 CHECK(group_it != group_map_.end()); | 856 CHECK(group_it != group_map_.end()); |
857 Group* group = group_it->second; | 857 Group* group = group_it->second; |
858 | 858 |
859 std::unique_ptr<StreamSocket> socket = job->PassSocket(); | 859 std::unique_ptr<StreamSocket> socket = job->PassSocket(); |
860 | 860 |
861 // Copies of these are needed because |job| may be deleted before they are | 861 // Copies of these are needed because |job| may be deleted before they are |
862 // accessed. | 862 // accessed. |
863 BoundNetLog job_log = job->net_log(); | 863 NetLogWithSource job_log = job->net_log(); |
864 LoadTimingInfo::ConnectTiming connect_timing = job->connect_timing(); | 864 LoadTimingInfo::ConnectTiming connect_timing = job->connect_timing(); |
865 | 865 |
866 // RemoveConnectJob(job, _) must be called by all branches below; | 866 // RemoveConnectJob(job, _) must be called by all branches below; |
867 // otherwise, |job| will be leaked. | 867 // otherwise, |job| will be leaked. |
868 | 868 |
869 if (result == OK) { | 869 if (result == OK) { |
870 DCHECK(socket.get()); | 870 DCHECK(socket.get()); |
871 RemoveConnectJob(job, group); | 871 RemoveConnectJob(job, group); |
872 std::unique_ptr<const Request> request = group->PopNextPendingRequest(); | 872 std::unique_ptr<const Request> request = group->PopNextPendingRequest(); |
873 if (request) { | 873 if (request) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 } | 966 } |
967 } | 967 } |
968 | 968 |
969 void ClientSocketPoolBaseHelper::HandOutSocket( | 969 void ClientSocketPoolBaseHelper::HandOutSocket( |
970 std::unique_ptr<StreamSocket> socket, | 970 std::unique_ptr<StreamSocket> socket, |
971 ClientSocketHandle::SocketReuseType reuse_type, | 971 ClientSocketHandle::SocketReuseType reuse_type, |
972 const LoadTimingInfo::ConnectTiming& connect_timing, | 972 const LoadTimingInfo::ConnectTiming& connect_timing, |
973 ClientSocketHandle* handle, | 973 ClientSocketHandle* handle, |
974 base::TimeDelta idle_time, | 974 base::TimeDelta idle_time, |
975 Group* group, | 975 Group* group, |
976 const BoundNetLog& net_log) { | 976 const NetLogWithSource& net_log) { |
977 DCHECK(socket); | 977 DCHECK(socket); |
978 handle->SetSocket(std::move(socket)); | 978 handle->SetSocket(std::move(socket)); |
979 handle->set_reuse_type(reuse_type); | 979 handle->set_reuse_type(reuse_type); |
980 handle->set_idle_time(idle_time); | 980 handle->set_idle_time(idle_time); |
981 handle->set_pool_id(pool_generation_number_); | 981 handle->set_pool_id(pool_generation_number_); |
982 handle->set_connect_timing(connect_timing); | 982 handle->set_connect_timing(connect_timing); |
983 | 983 |
984 if (reuse_type == ClientSocketHandle::REUSED_IDLE) { | 984 if (reuse_type == ClientSocketHandle::REUSED_IDLE) { |
985 net_log.AddEvent( | 985 net_log.AddEvent( |
986 NetLogEventType::SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, | 986 NetLogEventType::SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 // If there are no more requests, kill the backup timer. | 1325 // If there are no more requests, kill the backup timer. |
1326 if (pending_requests_.empty()) | 1326 if (pending_requests_.empty()) |
1327 backup_job_timer_.Stop(); | 1327 backup_job_timer_.Stop(); |
1328 request->CrashIfInvalid(); | 1328 request->CrashIfInvalid(); |
1329 return request; | 1329 return request; |
1330 } | 1330 } |
1331 | 1331 |
1332 } // namespace internal | 1332 } // namespace internal |
1333 | 1333 |
1334 } // namespace net | 1334 } // namespace net |
OLD | NEW |