Skip to content

Commit

Permalink
client side changes to run a field trial for page load metrics sender
Browse files Browse the repository at this point in the history
Bug: 847269
Change-Id: I9303c0cb0f770d61b25532b8f32d6b8edcd09731
Reviewed-on: https://chromium-review.googlesource.com/1075555
Commit-Queue: Luna Lu <[email protected]>
Reviewed-by: Bryan McQuade <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#562475}(cherry picked from commit 188a49e)
Reviewed-on: https://chromium-review.googlesource.com/1079735
Reviewed-by: Luna Lu <[email protected]>
Cr-Commit-Position: refs/branch-heads/3440@{#60}
Cr-Branched-From: 010ddcf-refs/heads/master@{#561733}
  • Loading branch information
loonybear committed May 31, 2018
1 parent dc5c21d commit 8597dad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions chrome/renderer/page_load_metrics/page_timing_metrics_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <utility>

#include "base/callback.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/common/page_load_metrics/page_load_metrics_constants.h"
Expand All @@ -16,6 +18,8 @@ namespace page_load_metrics {

namespace {
const int kInitialTimerDelayMillis = 50;
const base::Feature kPageLoadMetricsTimerDelayFeature{
"PageLoadMetricsTimerDelay", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace

PageTimingMetricsSender::PageTimingMetricsSender(
Expand All @@ -26,7 +30,11 @@ PageTimingMetricsSender::PageTimingMetricsSender(
timer_(std::move(timer)),
last_timing_(std::move(initial_timing)),
metadata_(mojom::PageLoadMetadata::New()),
new_features_(mojom::PageLoadFeatures::New()) {
new_features_(mojom::PageLoadFeatures::New()),
buffer_timer_delay_ms_(kBufferTimerDelayMillis) {
buffer_timer_delay_ms_ = base::GetFieldTrialParamByFeatureAsInt(
kPageLoadMetricsTimerDelayFeature, "BufferTimerDelayMillis",
kBufferTimerDelayMillis /* default value */);
if (!IsEmpty(*last_timing_)) {
EnsureSendTimer();
}
Expand Down Expand Up @@ -93,7 +101,7 @@ void PageTimingMetricsSender::EnsureSendTimer() {
// Send the first IPC eagerly to make sure the receiving side knows we're
// sending metrics as soon as possible.
int delay_ms =
have_sent_ipc_ ? kBufferTimerDelayMillis : kInitialTimerDelayMillis;
have_sent_ipc_ ? buffer_timer_delay_ms_ : kInitialTimerDelayMillis;
timer_->Start(
FROM_HERE, base::TimeDelta::FromMilliseconds(delay_ms),
base::Bind(&PageTimingMetricsSender::SendNow, base::Unretained(this)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class PageTimingMetricsSender {

bool have_sent_ipc_ = false;

// Field trial for alternating page timing metrics sender buffer timer delay.
// https://crbug.com/847269.
int buffer_timer_delay_ms_;

DISALLOW_COPY_AND_ASSIGN(PageTimingMetricsSender);
};

Expand Down

0 comments on commit 8597dad

Please sign in to comment.