Commit 5708ce2d authored by Zach Trudo's avatar Zach Trudo Committed by Commit Bot

Creates a standard reporting BackoffEntry

Reporting will regularly need to do exponential backoff on failed
requests. This CL creates a standard BackoffEntry object for managing
failed requests.

Bug: chromium:1078512
Change-Id: I51e9ac33a344e200e283731a9f98430e86920461
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276632Reviewed-by: default avatarLeonid Baraz <lbaraz@chromium.org>
Commit-Queue: Zach Trudo <zatrudo@google.com>
Cr-Commit-Position: refs/heads/master@{#784219}
parent bca3bcad
......@@ -1157,6 +1157,8 @@ static_library("browser") {
"policy/messaging_layer/storage/storage_module.h",
"policy/messaging_layer/storage/storage_queue.cc",
"policy/messaging_layer/storage/storage_queue.h",
"policy/messaging_layer/util/backoff_settings.cc",
"policy/messaging_layer/util/backoff_settings.h",
"policy/messaging_layer/util/status.cc",
"policy/messaging_layer/util/status.h",
"policy/messaging_layer/util/status_macros.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/policy/messaging_layer/util/backoff_settings.h"
#include <memory>
#include "net/base/backoff_entry.h"
namespace reporting {
std::unique_ptr<::net::BackoffEntry> GetBackoffEntry() {
// Retry starts with 10 second delay and is doubled with every failure.
static const net::BackoffEntry::Policy kDefaultUploadBackoffPolicy = {
// Number of initial errors to ignore before applying
// exponential back-off rules.
/*num_errors_to_ignore=*/0,
// Initial delay is 10 seconds.
/*initial_delay_ms=*/10 * 1000,
// Factor by which the waiting time will be multiplied.
/*multiply_factor=*/2,
// Fuzzing percentage.
/*jitter_factor=*/0.1,
// Maximum delay is 90 seconds.
/*maximum_backoff_ms=*/90 * 1000,
// It's up to the caller to reset the backoff time.
/*entry_lifetime_ms=*/-1,
/*always_use_initial_delay=*/true,
};
return std::make_unique<::net::BackoffEntry>(&kDefaultUploadBackoffPolicy);
}
} // namespace reporting
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_POLICY_MESSAGING_LAYER_UTIL_BACKOFF_SETTINGS_H_
#define CHROME_BROWSER_POLICY_MESSAGING_LAYER_UTIL_BACKOFF_SETTINGS_H_
#include <memory>
#include "net/base/backoff_entry.h"
namespace reporting {
// Returns a BackoffEntry object that defaults to initial 10 second delay and
// doubles the delay on every failure, to a maximum delay of 90 seconds.
// Caller owns the object and is responsible for resetting the delay on
// successful completion.
std::unique_ptr<::net::BackoffEntry> GetBackoffEntry();
} // namespace reporting
#endif // CHROME_BROWSER_POLICY_MESSAGING_LAYER_UTIL_BACKOFF_SETTINGS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment