| 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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 throttling_entry_(URLRequestThrottlerManager::GetInstance()-> | 257 throttling_entry_(URLRequestThrottlerManager::GetInstance()-> |
| 258 RegisterRequestUrl(request->url())), | 258 RegisterRequestUrl(request->url())), |
| 259 sdch_dictionary_advertised_(false), | 259 sdch_dictionary_advertised_(false), |
| 260 sdch_test_activated_(false), | 260 sdch_test_activated_(false), |
| 261 sdch_test_control_(false), | 261 sdch_test_control_(false), |
| 262 is_cached_content_(false), | 262 is_cached_content_(false), |
| 263 request_creation_time_(), | 263 request_creation_time_(), |
| 264 packet_timing_enabled_(false), | 264 packet_timing_enabled_(false), |
| 265 done_(false), | 265 done_(false), |
| 266 bytes_observed_in_packets_(0), | 266 bytes_observed_in_packets_(0), |
| 267 packet_times_(), | |
| 268 request_time_snapshot_(), | 267 request_time_snapshot_(), |
| 269 final_packet_time_(), | 268 final_packet_time_(), |
| 270 observed_packet_count_(0), | |
| 271 ALLOW_THIS_IN_INITIALIZER_LIST( | 269 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 272 filter_context_(new HttpFilterContext(this))), | 270 filter_context_(new HttpFilterContext(this))), |
| 273 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 271 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 274 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 272 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 275 ResetTimer(); | 273 ResetTimer(); |
| 276 } | 274 } |
| 277 | 275 |
| 278 void URLRequestHttpJob::NotifyHeadersComplete() { | 276 void URLRequestHttpJob::NotifyHeadersComplete() { |
| 279 DCHECK(!response_info_); | 277 DCHECK(!response_info_); |
| 280 | 278 |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1274 |
| 1277 void URLRequestHttpJob::UpdatePacketReadTimes() { | 1275 void URLRequestHttpJob::UpdatePacketReadTimes() { |
| 1278 if (!packet_timing_enabled_) | 1276 if (!packet_timing_enabled_) |
| 1279 return; | 1277 return; |
| 1280 | 1278 |
| 1281 if (filter_input_byte_count() <= bytes_observed_in_packets_) { | 1279 if (filter_input_byte_count() <= bytes_observed_in_packets_) { |
| 1282 DCHECK_EQ(filter_input_byte_count(), bytes_observed_in_packets_); | 1280 DCHECK_EQ(filter_input_byte_count(), bytes_observed_in_packets_); |
| 1283 return; // No new bytes have arrived. | 1281 return; // No new bytes have arrived. |
| 1284 } | 1282 } |
| 1285 | 1283 |
| 1284 final_packet_time_ = base::Time::Now(); |
| 1286 if (!bytes_observed_in_packets_) | 1285 if (!bytes_observed_in_packets_) |
| 1287 request_time_snapshot_ = request_ ? request_->request_time() : base::Time(); | 1286 request_time_snapshot_ = request_ ? request_->request_time() : base::Time(); |
| 1288 | 1287 |
| 1289 final_packet_time_ = base::Time::Now(); | |
| 1290 const size_t kTypicalPacketSize = 1430; | |
| 1291 while (filter_input_byte_count() > bytes_observed_in_packets_) { | |
| 1292 ++observed_packet_count_; | |
| 1293 if (packet_times_.size() < kSdchPacketHistogramCount) { | |
| 1294 packet_times_.push_back(final_packet_time_); | |
| 1295 DCHECK_EQ(static_cast<size_t>(observed_packet_count_), | |
| 1296 packet_times_.size()); | |
| 1297 } | |
| 1298 bytes_observed_in_packets_ += kTypicalPacketSize; | |
| 1299 } | |
| 1300 // Since packets may not be full, we'll remember the number of bytes we've | |
| 1301 // accounted for in packets thus far. | |
| 1302 bytes_observed_in_packets_ = filter_input_byte_count(); | 1288 bytes_observed_in_packets_ = filter_input_byte_count(); |
| 1303 } | 1289 } |
| 1304 | 1290 |
| 1305 void URLRequestHttpJob::RecordPacketStats( | 1291 void URLRequestHttpJob::RecordPacketStats( |
| 1306 FilterContext::StatisticSelector statistic) const { | 1292 FilterContext::StatisticSelector statistic) const { |
| 1307 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) | 1293 if (!packet_timing_enabled_ || (final_packet_time_ == base::Time())) |
| 1308 return; | 1294 return; |
| 1309 | 1295 |
| 1310 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_; | 1296 base::TimeDelta duration = final_packet_time_ - request_time_snapshot_; |
| 1311 switch (statistic) { | 1297 switch (statistic) { |
| 1312 case FilterContext::SDCH_DECODE: { | 1298 case FilterContext::SDCH_DECODE: { |
| 1313 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Decode_Latency_F_a", duration, | |
| 1314 base::TimeDelta::FromMilliseconds(20), | |
| 1315 base::TimeDelta::FromMinutes(10), 100); | |
| 1316 UMA_HISTOGRAM_COUNTS_100("Sdch3.Network_Decode_Packets_b", | |
| 1317 static_cast<int>(observed_packet_count_)); | |
| 1318 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b", | 1299 UMA_HISTOGRAM_CUSTOM_COUNTS("Sdch3.Network_Decode_Bytes_Processed_b", |
| 1319 static_cast<int>(bytes_observed_in_packets_), 500, 100000, 100); | 1300 static_cast<int>(bytes_observed_in_packets_), 500, 100000, 100); |
| 1320 if (packet_times_.empty()) | |
| 1321 return; | |
| 1322 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Decode_1st_To_Last_a", | |
| 1323 final_packet_time_ - packet_times_[0], | |
| 1324 base::TimeDelta::FromMilliseconds(20), | |
| 1325 base::TimeDelta::FromMinutes(10), 100); | |
| 1326 | |
| 1327 DCHECK_GT(kSdchPacketHistogramCount, 4u); | |
| 1328 if (packet_times_.size() <= 4) | |
| 1329 return; | |
| 1330 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Decode_1st_To_2nd_c", | |
| 1331 packet_times_[1] - packet_times_[0], | |
| 1332 base::TimeDelta::FromMilliseconds(1), | |
| 1333 base::TimeDelta::FromSeconds(10), 100); | |
| 1334 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Decode_2nd_To_3rd_c", | |
| 1335 packet_times_[2] - packet_times_[1], | |
| 1336 base::TimeDelta::FromMilliseconds(1), | |
| 1337 base::TimeDelta::FromSeconds(10), 100); | |
| 1338 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Decode_3rd_To_4th_c", | |
| 1339 packet_times_[3] - packet_times_[2], | |
| 1340 base::TimeDelta::FromMilliseconds(1), | |
| 1341 base::TimeDelta::FromSeconds(10), 100); | |
| 1342 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Decode_4th_To_5th_c", | |
| 1343 packet_times_[4] - packet_times_[3], | |
| 1344 base::TimeDelta::FromMilliseconds(1), | |
| 1345 base::TimeDelta::FromSeconds(10), 100); | |
| 1346 return; | 1301 return; |
| 1347 } | 1302 } |
| 1348 case FilterContext::SDCH_PASSTHROUGH: { | 1303 case FilterContext::SDCH_PASSTHROUGH: { |
| 1349 // Despite advertising a dictionary, we handled non-sdch compressed | 1304 // Despite advertising a dictionary, we handled non-sdch compressed |
| 1350 // content. | 1305 // content. |
| 1351 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Pass-through_Latency_F_a", | |
| 1352 duration, | |
| 1353 base::TimeDelta::FromMilliseconds(20), | |
| 1354 base::TimeDelta::FromMinutes(10), 100); | |
| 1355 UMA_HISTOGRAM_COUNTS_100("Sdch3.Network_Pass-through_Packets_b", | |
| 1356 observed_packet_count_); | |
| 1357 if (packet_times_.empty()) | |
| 1358 return; | |
| 1359 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Pass-through_1st_To_Last_a", | |
| 1360 final_packet_time_ - packet_times_[0], | |
| 1361 base::TimeDelta::FromMilliseconds(20), | |
| 1362 base::TimeDelta::FromMinutes(10), 100); | |
| 1363 DCHECK_GT(kSdchPacketHistogramCount, 4u); | |
| 1364 if (packet_times_.size() <= 4) | |
| 1365 return; | |
| 1366 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Pass-through_1st_To_2nd_c", | |
| 1367 packet_times_[1] - packet_times_[0], | |
| 1368 base::TimeDelta::FromMilliseconds(1), | |
| 1369 base::TimeDelta::FromSeconds(10), 100); | |
| 1370 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Pass-through_2nd_To_3rd_c", | |
| 1371 packet_times_[2] - packet_times_[1], | |
| 1372 base::TimeDelta::FromMilliseconds(1), | |
| 1373 base::TimeDelta::FromSeconds(10), 100); | |
| 1374 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Pass-through_3rd_To_4th_c", | |
| 1375 packet_times_[3] - packet_times_[2], | |
| 1376 base::TimeDelta::FromMilliseconds(1), | |
| 1377 base::TimeDelta::FromSeconds(10), 100); | |
| 1378 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Pass-through_4th_To_5th_c", | |
| 1379 packet_times_[4] - packet_times_[3], | |
| 1380 base::TimeDelta::FromMilliseconds(1), | |
| 1381 base::TimeDelta::FromSeconds(10), 100); | |
| 1382 return; | 1306 return; |
| 1383 } | 1307 } |
| 1384 | 1308 |
| 1385 case FilterContext::SDCH_EXPERIMENT_DECODE: { | 1309 case FilterContext::SDCH_EXPERIMENT_DECODE: { |
| 1386 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Experiment_Decode", | 1310 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment2_Decode", |
| 1387 duration, | 1311 duration, |
| 1388 base::TimeDelta::FromMilliseconds(20), | 1312 base::TimeDelta::FromMilliseconds(20), |
| 1389 base::TimeDelta::FromMinutes(10), 100); | 1313 base::TimeDelta::FromMinutes(10), 100); |
| 1390 // We already provided interpacket histograms above in the SDCH_DECODE | |
| 1391 // case, so we don't need them here. | |
| 1392 return; | 1314 return; |
| 1393 } | 1315 } |
| 1394 case FilterContext::SDCH_EXPERIMENT_HOLDBACK: { | 1316 case FilterContext::SDCH_EXPERIMENT_HOLDBACK: { |
| 1395 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Experiment_Holdback", | 1317 UMA_HISTOGRAM_CUSTOM_TIMES("Sdch3.Experiment2_Holdback", |
| 1396 duration, | 1318 duration, |
| 1397 base::TimeDelta::FromMilliseconds(20), | 1319 base::TimeDelta::FromMilliseconds(20), |
| 1398 base::TimeDelta::FromMinutes(10), 100); | 1320 base::TimeDelta::FromMinutes(10), 100); |
| 1399 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Experiment_Holdback_1st_To_Last_a", | |
| 1400 final_packet_time_ - packet_times_[0], | |
| 1401 base::TimeDelta::FromMilliseconds(20), | |
| 1402 base::TimeDelta::FromMinutes(10), 100); | |
| 1403 | |
| 1404 DCHECK_GT(kSdchPacketHistogramCount, 4u); | |
| 1405 if (packet_times_.size() <= 4) | |
| 1406 return; | |
| 1407 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Experiment_Holdback_1st_To_2nd_c", | |
| 1408 packet_times_[1] - packet_times_[0], | |
| 1409 base::TimeDelta::FromMilliseconds(1), | |
| 1410 base::TimeDelta::FromSeconds(10), 100); | |
| 1411 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Experiment_Holdback_2nd_To_3rd_c", | |
| 1412 packet_times_[2] - packet_times_[1], | |
| 1413 base::TimeDelta::FromMilliseconds(1), | |
| 1414 base::TimeDelta::FromSeconds(10), 100); | |
| 1415 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Experiment_Holdback_3rd_To_4th_c", | |
| 1416 packet_times_[3] - packet_times_[2], | |
| 1417 base::TimeDelta::FromMilliseconds(1), | |
| 1418 base::TimeDelta::FromSeconds(10), 100); | |
| 1419 UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Experiment_Holdback_4th_To_5th_c", | |
| 1420 packet_times_[4] - packet_times_[3], | |
| 1421 base::TimeDelta::FromMilliseconds(1), | |
| 1422 base::TimeDelta::FromSeconds(10), 100); | |
| 1423 return; | 1321 return; |
| 1424 } | 1322 } |
| 1425 default: | 1323 default: |
| 1426 NOTREACHED(); | 1324 NOTREACHED(); |
| 1427 return; | 1325 return; |
| 1428 } | 1326 } |
| 1429 } | 1327 } |
| 1430 | 1328 |
| 1431 // The common type of histogram we use for all compression-tracking histograms. | 1329 // The common type of histogram we use for all compression-tracking histograms. |
| 1432 #define COMPRESSION_HISTOGRAM(name, sample) \ | 1330 #define COMPRESSION_HISTOGRAM(name, sample) \ |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 if (done_) | 1461 if (done_) |
| 1564 return; | 1462 return; |
| 1565 done_ = true; | 1463 done_ = true; |
| 1566 | 1464 |
| 1567 RecordPerfHistograms(reason); | 1465 RecordPerfHistograms(reason); |
| 1568 if (reason == FINISHED) | 1466 if (reason == FINISHED) |
| 1569 RecordCompressionHistograms(); | 1467 RecordCompressionHistograms(); |
| 1570 } | 1468 } |
| 1571 | 1469 |
| 1572 } // namespace net | 1470 } // namespace net |
| OLD | NEW |