Commit 5b722389 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Fix static initializers in ftl_services_context.cc.

Calculate |kBackoffPolicy| on first use at a local scope instead.
Because base::TimeDelta::InMilliseconds() and friends are not constexpr,
a global that calls them must do so during process startup.

Remove deprecated DISALLOW_IMPLICIT_CONSTRUCTORS() usage along the way.

Bug: 537099
Change-Id: If1680816bc18107f7b15e366e205b409c92bf0b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2430299Reviewed-by: default avatarYuwei Huang <yuweih@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810860}
parent 4590f8b3
......@@ -4,10 +4,7 @@
#include "remoting/signaling/ftl_services_context.h"
#include <utility>
#include "base/guid.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "google_apis/google_api_keys.h"
#include "remoting/base/service_urls.h"
......@@ -18,39 +15,39 @@ namespace {
constexpr char kChromotingAppIdentifier[] = "CRD";
const net::BackoffEntry::Policy kBackoffPolicy = {
// Number of initial errors (in sequence) to ignore before applying
// exponential back-off rules.
0,
} // namespace
// Initial delay for exponential back-off in ms.
FtlServicesContext::kBackoffInitialDelay.InMilliseconds(),
constexpr base::TimeDelta FtlServicesContext::kBackoffInitialDelay;
constexpr base::TimeDelta FtlServicesContext::kBackoffMaxDelay;
// Factor by which the waiting time will be multiplied.
2,
// static
const net::BackoffEntry::Policy& FtlServicesContext::GetBackoffPolicy() {
static const net::BackoffEntry::Policy kBackoffPolicy = {
// Number of initial errors (in sequence) to ignore before applying
// exponential back-off rules.
0,
// Fuzzing percentage. ex: 10% will spread requests randomly
// between 90%-100% of the calculated time.
0.5,
// Initial delay for exponential back-off in ms.
kBackoffInitialDelay.InMilliseconds(),
// Maximum amount of time we are willing to delay our request in ms.
FtlServicesContext::kBackoffMaxDelay.InMilliseconds(),
// Factor by which the waiting time will be multiplied.
2,
// Time to keep an entry from being discarded even when it
// has no significant state, -1 to never discard.
-1,
// Fuzzing percentage. ex: 10% will spread requests randomly
// between 90%-100% of the calculated time.
0.5,
// Starts with initial delay.
false,
};
// Maximum amount of time we are willing to delay our request in ms.
kBackoffMaxDelay.InMilliseconds(),
} // namespace
// Time to keep an entry from being discarded even when it
// has no significant state, -1 to never discard.
-1,
constexpr base::TimeDelta FtlServicesContext::kBackoffInitialDelay;
constexpr base::TimeDelta FtlServicesContext::kBackoffMaxDelay;
// Starts with initial delay.
false,
};
// static
const net::BackoffEntry::Policy& FtlServicesContext::GetBackoffPolicy() {
return kBackoffPolicy;
}
......
......@@ -5,10 +5,9 @@
#ifndef REMOTING_SIGNALING_FTL_SERVICES_CONTEXT_H_
#define REMOTING_SIGNALING_FTL_SERVICES_CONTEXT_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/time/time.h"
#include "net/base/backoff_entry.h"
#include "remoting/proto/ftl/v1/ftl_messages.pb.h"
......@@ -18,6 +17,7 @@ namespace remoting {
// to FTL backend.
class FtlServicesContext final {
public:
// Exposed for testing.
static constexpr base::TimeDelta kBackoffInitialDelay =
base::TimeDelta::FromSeconds(1);
static constexpr base::TimeDelta kBackoffMaxDelay =
......@@ -30,8 +30,9 @@ class FtlServicesContext final {
static ftl::RequestHeader CreateRequestHeader(
const std::string& ftl_auth_token = {});
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(FtlServicesContext);
FtlServicesContext() = delete;
FtlServicesContext(const FtlServicesContext&) = delete;
FtlServicesContext& operator=(const FtlServicesContext&) = delete;
};
} // namespace remoting
......
......@@ -38,7 +38,6 @@ _CROS_SI_FILE_ALLOWLIST = {
'spinlock.cc', # TODO(crbug.com/973556): Remove.
'crash_report_private_api.cc', # TODO(crbug.com/537099): Remove.
'dlcservice_client.cc', # TODO(crbug.com/537099): Remove.
'ftl_services_context.cc', # TODO(crbug.com/537099): Remove.
'hud_display.cc', # TODO(crbug.com/537099): Remove.
'int256.cc', # TODO(crbug.com/537099): Remove.
'native_message_host_chromeos.cc', # TODO(crbug.com/537099): Remove.
......
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