Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1839)

Unified Diff: chrome/browser/metrics/variations_service.cc

Issue 10828255: Revert 150949 - Have the VariationsService attempt to fetch the seed when an update is ready. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/variations_service.h ('k') | chrome/browser/metrics/variations_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/variations_service.cc
===================================================================
--- chrome/browser/metrics/variations_service.cc (revision 151030)
+++ chrome/browser/metrics/variations_service.cc (working copy)
@@ -16,13 +16,10 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/proto/trials_seed.pb.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/upgrade_detector.h"
-#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/metrics/experiments_helper.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/common/url_fetcher.h"
#include "googleurl/src/gurl.h"
#include "net/base/load_flags.h"
@@ -35,7 +32,7 @@
namespace {
-// Default server of variations seed info.
+// Default server of Variations seed info.
const char kDefaultVariationsServerURL[] =
"https://clients4.google.com/chrome-variations/seed";
const int kMaxRetrySeedFetch = 5;
@@ -87,7 +84,7 @@
return base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(date_time);
}
-// Determine and return the Variations server URL.
+// Determine and return the variations server URL.
GURL GetVariationsServerURL() {
std::string server_url(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kVariationsServerURL));
@@ -103,8 +100,6 @@
VariationsService::VariationsService()
: variations_server_url_(GetVariationsServerURL()),
create_trials_from_seed_called_(false) {
- registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
- content::Source<UpgradeDetector>(UpgradeDetector::GetInstance()));
}
VariationsService::~VariationsService() {}
@@ -138,7 +133,7 @@
}
void VariationsService::StartRepeatedVariationsSeedFetch() {
- DCHECK(CalledOnValidThread());
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
// Check that |CreateTrialsFromSeed| was called, which is necessary to
// retrieve the serial number that will be sent to the server.
@@ -152,15 +147,8 @@
this, &VariationsService::FetchVariationsSeed);
}
-// static
-void VariationsService::RegisterPrefs(PrefService* prefs) {
- prefs->RegisterStringPref(prefs::kVariationsSeed, std::string());
- prefs->RegisterInt64Pref(prefs::kVariationsSeedDate,
- base::Time().ToInternalValue());
-}
-
void VariationsService::FetchVariationsSeed() {
- DCHECK(CalledOnValidThread());
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
const bool is_offline = net::NetworkChangeNotifier::IsOffline();
UMA_HISTOGRAM_BOOLEAN("Variations.NetworkAvailability", !is_offline);
@@ -183,22 +171,6 @@
pending_seed_request_->Start();
}
-void VariationsService::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(CalledOnValidThread());
- DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type);
-
- // An upgrade is ready, so attempt to fetch the Variations seed in case there
- // were updates.
- FetchVariationsSeed();
-
- // Since we explicitly call FetchVariationsSeed here, we can reset the timer
- // so that we don't retry for another full period.
- if (timer_.IsRunning())
- timer_.Reset();
-}
-
void VariationsService::OnURLFetchComplete(const net::URLFetcher* source) {
DCHECK_EQ(pending_seed_request_.get(), source);
// When we're done handling the request, the fetcher will be deleted.
@@ -226,6 +198,13 @@
StoreSeedData(seed_data, response_date, g_browser_process->local_state());
}
+// static
+void VariationsService::RegisterPrefs(PrefService* prefs) {
+ prefs->RegisterStringPref(prefs::kVariationsSeed, std::string());
+ prefs->RegisterInt64Pref(prefs::kVariationsSeedDate,
+ base::Time().ToInternalValue());
+}
+
bool VariationsService::StoreSeedData(const std::string& seed_data,
const base::Time& seed_date,
PrefService* local_prefs) {
« no previous file with comments | « chrome/browser/metrics/variations_service.h ('k') | chrome/browser/metrics/variations_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698