OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <functional> | 9 #include <functional> |
10 #include <memory> | 10 #include <memory> |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 ValidateLoFiInPingback(false); | 411 ValidateLoFiInPingback(false); |
412 | 412 |
413 ResetTest(); | 413 ResetTest(); |
414 | 414 |
415 std::unique_ptr<DataReductionProxyData> data = | 415 std::unique_ptr<DataReductionProxyData> data = |
416 base::MakeUnique<DataReductionProxyData>(); | 416 base::MakeUnique<DataReductionProxyData>(); |
417 data->set_used_data_reduction_proxy(true); | 417 data->set_used_data_reduction_proxy(true); |
418 data->set_lofi_received(true); | 418 data->set_lofi_received(true); |
419 | 419 |
420 // Verify LoFi is tracked when a LoFi response is received. | 420 // Verify LoFi is tracked when a LoFi response is received. |
421 page_load_metrics::ExtraRequestInfo resource = { | 421 page_load_metrics::ExtraRequestCompleteInfo resource = { |
422 true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 422 true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
423 0 /* original_network_content_length */, std::move(data)}; | 423 0 /* original_network_content_length */, std::move(data), |
| 424 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}; |
424 | 425 |
425 RunTest(true, false); | 426 RunTest(true, false); |
426 SimulateLoadedResource(resource); | 427 SimulateLoadedResource(resource); |
427 NavigateToUntrackedUrl(); | 428 NavigateToUntrackedUrl(); |
428 ValidateTimes(); | 429 ValidateTimes(); |
429 ValidateLoFiInPingback(true); | 430 ValidateLoFiInPingback(true); |
430 | 431 |
431 ResetTest(); | 432 ResetTest(); |
432 // Verify that when data reduction proxy was not used, SendPingback is not | 433 // Verify that when data reduction proxy was not used, SendPingback is not |
433 // called. | 434 // called. |
(...skipping 12 matching lines...) Expand all Loading... |
446 TEST_F(DataReductionProxyMetricsObserverTest, ByteInformationCompression) { | 447 TEST_F(DataReductionProxyMetricsObserverTest, ByteInformationCompression) { |
447 ResetTest(); | 448 ResetTest(); |
448 | 449 |
449 RunTest(true, false); | 450 RunTest(true, false); |
450 | 451 |
451 std::unique_ptr<DataReductionProxyData> data = | 452 std::unique_ptr<DataReductionProxyData> data = |
452 base::MakeUnique<DataReductionProxyData>(); | 453 base::MakeUnique<DataReductionProxyData>(); |
453 data->set_used_data_reduction_proxy(true); | 454 data->set_used_data_reduction_proxy(true); |
454 | 455 |
455 // Prepare 4 resources of varying size and configurations. | 456 // Prepare 4 resources of varying size and configurations. |
456 page_load_metrics::ExtraRequestInfo resources[] = { | 457 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
457 // Cached request. | 458 // Cached request. |
458 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 459 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
459 0 /* original_network_content_length */, | 460 0 /* original_network_content_length */, |
460 nullptr /* data_reduction_proxy_data */}, | 461 nullptr /* data_reduction_proxy_data */, |
| 462 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
461 // Uncached non-proxied request. | 463 // Uncached non-proxied request. |
462 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 464 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
463 1024 * 40 /* original_network_content_length */, | 465 1024 * 40 /* original_network_content_length */, |
464 nullptr /* data_reduction_proxy_data */}, | 466 nullptr /* data_reduction_proxy_data */, |
| 467 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
465 // Uncached proxied request with .1 compression ratio. | 468 // Uncached proxied request with .1 compression ratio. |
466 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 469 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
467 1024 * 40 * 10 /* original_network_content_length */, data->DeepCopy()}, | 470 1024 * 40 * 10 /* original_network_content_length */, data->DeepCopy(), |
| 471 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
468 // Uncached proxied request with .5 compression ratio. | 472 // Uncached proxied request with .5 compression ratio. |
469 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 473 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
470 1024 * 40 * 5 /* original_network_content_length */, std::move(data)}, | 474 1024 * 40 * 5 /* original_network_content_length */, std::move(data), |
| 475 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
471 }; | 476 }; |
472 | 477 |
473 int network_resources = 0; | 478 int network_resources = 0; |
474 int drp_resources = 0; | 479 int drp_resources = 0; |
475 int64_t network_bytes = 0; | 480 int64_t network_bytes = 0; |
476 int64_t drp_bytes = 0; | 481 int64_t drp_bytes = 0; |
477 int64_t ocl_bytes = 0; | 482 int64_t ocl_bytes = 0; |
478 for (const auto& request : resources) { | 483 for (const auto& request : resources) { |
479 SimulateLoadedResource(request); | 484 SimulateLoadedResource(request); |
480 if (!request.was_cached) { | 485 if (!request.was_cached) { |
(...skipping 17 matching lines...) Expand all Loading... |
498 TEST_F(DataReductionProxyMetricsObserverTest, ByteInformationInflation) { | 503 TEST_F(DataReductionProxyMetricsObserverTest, ByteInformationInflation) { |
499 ResetTest(); | 504 ResetTest(); |
500 | 505 |
501 RunTest(true, false); | 506 RunTest(true, false); |
502 | 507 |
503 std::unique_ptr<DataReductionProxyData> data = | 508 std::unique_ptr<DataReductionProxyData> data = |
504 base::MakeUnique<DataReductionProxyData>(); | 509 base::MakeUnique<DataReductionProxyData>(); |
505 data->set_used_data_reduction_proxy(true); | 510 data->set_used_data_reduction_proxy(true); |
506 | 511 |
507 // Prepare 4 resources of varying size and configurations. | 512 // Prepare 4 resources of varying size and configurations. |
508 page_load_metrics::ExtraRequestInfo resources[] = { | 513 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
509 // Cached request. | 514 // Cached request. |
510 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 515 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
511 0 /* original_network_content_length */, | 516 0 /* original_network_content_length */, |
512 nullptr /* data_reduction_proxy_data */}, | 517 nullptr /* data_reduction_proxy_data */, |
| 518 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
513 // Uncached non-proxied request. | 519 // Uncached non-proxied request. |
514 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 520 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
515 1024 * 40 /* original_network_content_length */, | 521 1024 * 40 /* original_network_content_length */, |
516 nullptr /* data_reduction_proxy_data */}, | 522 nullptr /* data_reduction_proxy_data */, |
| 523 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
517 // Uncached proxied request with .1 compression ratio. | 524 // Uncached proxied request with .1 compression ratio. |
518 {false /*was_cached*/, 1024 * 40 * 10 /* raw_body_bytes */, | 525 {false /*was_cached*/, 1024 * 40 * 10 /* raw_body_bytes */, |
519 1024 * 40 /* original_network_content_length */, data->DeepCopy()}, | 526 1024 * 40 /* original_network_content_length */, data->DeepCopy(), |
| 527 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
520 // Uncached proxied request with .5 compression ratio. | 528 // Uncached proxied request with .5 compression ratio. |
521 {false /*was_cached*/, 1024 * 40 * 5 /* raw_body_bytes */, | 529 {false /*was_cached*/, 1024 * 40 * 5 /* raw_body_bytes */, |
522 1024 * 40 /* original_network_content_length */, std::move(data)}, | 530 1024 * 40 /* original_network_content_length */, std::move(data), |
| 531 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
523 }; | 532 }; |
524 | 533 |
525 int network_resources = 0; | 534 int network_resources = 0; |
526 int drp_resources = 0; | 535 int drp_resources = 0; |
527 int64_t network_bytes = 0; | 536 int64_t network_bytes = 0; |
528 int64_t drp_bytes = 0; | 537 int64_t drp_bytes = 0; |
529 int64_t ocl_bytes = 0; | 538 int64_t ocl_bytes = 0; |
530 for (const auto& request : resources) { | 539 for (const auto& request : resources) { |
531 SimulateLoadedResource(request); | 540 SimulateLoadedResource(request); |
532 if (!request.was_cached) { | 541 if (!request.was_cached) { |
533 network_bytes += request.raw_body_bytes; | 542 network_bytes += request.raw_body_bytes; |
534 ocl_bytes += request.original_network_content_length; | 543 ocl_bytes += request.original_network_content_length; |
535 ++network_resources; | 544 ++network_resources; |
536 } | 545 } |
537 if (request.data_reduction_proxy_data && | 546 if (request.data_reduction_proxy_data && |
538 request.data_reduction_proxy_data->used_data_reduction_proxy()) { | 547 request.data_reduction_proxy_data->used_data_reduction_proxy()) { |
539 drp_bytes += request.raw_body_bytes; | 548 drp_bytes += request.raw_body_bytes; |
540 ++drp_resources; | 549 ++drp_resources; |
541 } | 550 } |
542 } | 551 } |
543 | 552 |
544 NavigateToUntrackedUrl(); | 553 NavigateToUntrackedUrl(); |
545 | 554 |
546 ValidateDataHistograms(network_resources, drp_resources, network_bytes, | 555 ValidateDataHistograms(network_resources, drp_resources, network_bytes, |
547 drp_bytes, ocl_bytes); | 556 drp_bytes, ocl_bytes); |
548 } | 557 } |
549 | 558 |
550 } // namespace data_reduction_proxy | 559 } // namespace data_reduction_proxy |
OLD | NEW |