Commit 0bbe1310 authored by glevin's avatar glevin Committed by Commit bot

Remove first check random delay on older devices

BUG=598841
TEST=Not easily testable, as this CL removes code that is no longer
active after a first Quirks server check; we expect nearly all devices
should have made a server check as of M-54, if they're ever going to.

Review-Url: https://codereview.chromium.org/2006143011
Cr-Commit-Position: refs/heads/master@{#404587}
parent 850dda6b
...@@ -95,10 +95,6 @@ class QuirksManagerDelegateTestImpl : public quirks::QuirksManager::Delegate { ...@@ -95,10 +95,6 @@ class QuirksManagerDelegateTestImpl : public quirks::QuirksManager::Delegate {
// |false| prevents attempts at Quirks Server contact. // |false| prevents attempts at Quirks Server contact.
bool DevicePolicyEnabled() const override { return false; } bool DevicePolicyEnabled() const override { return false; }
// Unused by these tests.
void GetDaysSinceOobe(
quirks::QuirksManager::DaysSinceOobeCallback callback) const override {}
private: private:
~QuirksManagerDelegateTestImpl() override = default; ~QuirksManagerDelegateTestImpl() override = default;
......
...@@ -6,23 +6,15 @@ ...@@ -6,23 +6,15 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chromeos/chromeos_paths.h" #include "chromeos/chromeos_paths.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/google_api_keys.h" #include "google_apis/google_api_keys.h"
namespace { namespace {
const char kUserDataDisplayProfilesDirectory[] = "display_profiles"; const char kUserDataDisplayProfilesDirectory[] = "display_profiles";
int GetDaysSinceOobeOnBlockingPool() {
return chromeos::StartupUtils::GetTimeSinceOobeFlagFileCreation().InDays();
}
} // namespace } // namespace
namespace quirks { namespace quirks {
...@@ -60,11 +52,4 @@ bool QuirksManagerDelegateImpl::DevicePolicyEnabled() const { ...@@ -60,11 +52,4 @@ bool QuirksManagerDelegateImpl::DevicePolicyEnabled() const {
return quirks_enabled; return quirks_enabled;
} }
void QuirksManagerDelegateImpl::GetDaysSinceOobe(
QuirksManager::DaysSinceOobeCallback callback) const {
base::PostTaskAndReplyWithResult(
content::BrowserThread::GetBlockingPool(), FROM_HERE,
base::Bind(&GetDaysSinceOobeOnBlockingPool), callback);
}
} // namespace quirks } // namespace quirks
...@@ -21,8 +21,6 @@ class QuirksManagerDelegateImpl : public QuirksManager::Delegate { ...@@ -21,8 +21,6 @@ class QuirksManagerDelegateImpl : public QuirksManager::Delegate {
base::FilePath GetBuiltInDisplayProfileDirectory() const override; base::FilePath GetBuiltInDisplayProfileDirectory() const override;
base::FilePath GetDownloadDisplayProfileDirectory() const override; base::FilePath GetDownloadDisplayProfileDirectory() const override;
bool DevicePolicyEnabled() const override; bool DevicePolicyEnabled() const override;
void GetDaysSinceOobe(
QuirksManager::DaysSinceOobeCallback callback) const override;
private: private:
~QuirksManagerDelegateImpl() override = default; ~QuirksManagerDelegateImpl() override = default;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
...@@ -46,7 +45,6 @@ base::FilePath CheckForIccFile(base::FilePath built_in_path, ...@@ -46,7 +45,6 @@ base::FilePath CheckForIccFile(base::FilePath built_in_path,
bool quirks_enabled) { bool quirks_enabled) {
// First, look for icc file in old read-only location. If there, we don't use // First, look for icc file in old read-only location. If there, we don't use
// the Quirks server. // the Quirks server.
// TODO(glevin): Awaiting final decision on how to handle old read-only files.
if (CheckAndLogFile(built_in_path)) if (CheckAndLogFile(built_in_path))
return built_in_path; return built_in_path;
...@@ -189,14 +187,6 @@ void QuirksManager::OnIccFilePathRequestCompleted( ...@@ -189,14 +187,6 @@ void QuirksManager::OnIccFilePathRequestCompleted(
local_state_->GetDictionary(prefs::kQuirksClientLastServerCheck) local_state_->GetDictionary(prefs::kQuirksClientLastServerCheck)
->GetDouble(IdToHexString(product_id), &last_check); ->GetDouble(IdToHexString(product_id), &last_check);
// If never checked server before, need to check for new device.
if (last_check == 0.0) {
delegate_->GetDaysSinceOobe(base::Bind(
&QuirksManager::OnDaysSinceOobeReceived, weak_ptr_factory_.GetWeakPtr(),
product_id, on_request_finished));
return;
}
const base::TimeDelta time_since = const base::TimeDelta time_since =
base::Time::Now() - base::Time::FromDoubleT(last_check); base::Time::Now() - base::Time::FromDoubleT(last_check);
...@@ -209,38 +199,7 @@ void QuirksManager::OnIccFilePathRequestCompleted( ...@@ -209,38 +199,7 @@ void QuirksManager::OnIccFilePathRequestCompleted(
return; return;
} }
CreateClient(product_id, on_request_finished); // Create and start a client to download file.
}
void QuirksManager::OnDaysSinceOobeReceived(
int64_t product_id,
const RequestFinishedCallback& on_request_finished,
int days_since_oobe) {
DCHECK(thread_checker_.CalledOnValidThread());
// On newer devices, we want to check server immediately (after OOBE/login).
if (days_since_oobe <= kDaysBetweenServerChecks) {
CreateClient(product_id, on_request_finished);
return;
}
// Otherwise, for the first check on an older device, we want to stagger
// it over 30 days, so artificially set last check accordingly.
// TODO(glevin): I believe that it makes sense to remove this random delay
// in the next Chrome release.
const int rand_days = base::RandInt(0, kDaysBetweenServerChecks);
const base::Time fake_last_check =
base::Time::Now() - base::TimeDelta::FromDays(rand_days);
SetLastServerCheck(product_id, fake_last_check);
VLOG(2) << "Delaying first Quirks Server check by "
<< kDaysBetweenServerChecks - rand_days << " days.";
on_request_finished.Run(base::FilePath(), false);
}
void QuirksManager::CreateClient(
int64_t product_id,
const RequestFinishedCallback& on_request_finished) {
DCHECK(thread_checker_.CalledOnValidThread());
QuirksClient* client = QuirksClient* client =
new QuirksClient(product_id, on_request_finished, this); new QuirksClient(product_id, on_request_finished, this);
clients_.insert(base::WrapUnique(client)); clients_.insert(base::WrapUnique(client));
......
...@@ -57,10 +57,6 @@ class QUIRKS_EXPORT QuirksManager { ...@@ -57,10 +57,6 @@ class QUIRKS_EXPORT QuirksManager {
using FakeQuirksFetcherCreator = base::Callback< using FakeQuirksFetcherCreator = base::Callback<
std::unique_ptr<net::URLFetcher>(const GURL&, net::URLFetcherDelegate*)>; std::unique_ptr<net::URLFetcher>(const GURL&, net::URLFetcherDelegate*)>;
// Callback after getting days since OOBE on blocking pool.
// Parameter is returned number of days.
using DaysSinceOobeCallback = base::Callback<void(int)>;
// Delegate class, so implementation can access browser functionality. // Delegate class, so implementation can access browser functionality.
class Delegate { class Delegate {
public: public:
...@@ -80,9 +76,6 @@ class QUIRKS_EXPORT QuirksManager { ...@@ -80,9 +76,6 @@ class QUIRKS_EXPORT QuirksManager {
// Whether downloads are allowed by enterprise device policy. // Whether downloads are allowed by enterprise device policy.
virtual bool DevicePolicyEnabled() const = 0; virtual bool DevicePolicyEnabled() const = 0;
// Gets days since first login, returned via callback.
virtual void GetDaysSinceOobe(DaysSinceOobeCallback callback) const = 0;
private: private:
DISALLOW_ASSIGN(Delegate); DISALLOW_ASSIGN(Delegate);
}; };
...@@ -139,16 +132,6 @@ class QUIRKS_EXPORT QuirksManager { ...@@ -139,16 +132,6 @@ class QUIRKS_EXPORT QuirksManager {
const RequestFinishedCallback& on_request_finished, const RequestFinishedCallback& on_request_finished,
base::FilePath path); base::FilePath path);
// Callback after checking OOBE date; launch client if appropriate.
void OnDaysSinceOobeReceived(
int64_t product_id,
const RequestFinishedCallback& on_request_finished,
int days_since_oobe);
// Create and start a client to download file.
void CreateClient(int64_t product_id,
const RequestFinishedCallback& on_request_finished);
// Whether downloads allowed by cmd line flag and device policy. // Whether downloads allowed by cmd line flag and device policy.
bool QuirksEnabled(); bool QuirksEnabled();
......
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