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