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

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

Issue 10828106: Support serial number requests in variations service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
Index: chrome/browser/metrics/variations_service.cc
===================================================================
--- chrome/browser/metrics/variations_service.cc (revision 149502)
+++ chrome/browser/metrics/variations_service.cc (working copy)
@@ -98,12 +98,15 @@
} // namespace
VariationsService::VariationsService()
- : variations_server_url_(GetVariationsServerURL()) {
+ : variations_server_url_(GetVariationsServerURL()),
+ create_trials_from_seed_called_(false) {
}
VariationsService::~VariationsService() {}
bool VariationsService::CreateTrialsFromSeed(PrefService* local_prefs) {
+ create_trials_from_seed_called_ = true;
Ilya Sherman 2012/08/02 23:40:49 nit: Is it ok that this method can return |false|
Alexei Svitkine (slow) 2012/08/02 23:51:02 Right, it's just making sure we don't lose the opt
+
TrialsSeed seed;
if (!LoadTrialsSeedFromPref(local_prefs, &seed))
return false;
@@ -132,6 +135,10 @@
void VariationsService::StartRepeatedVariationsSeedFetch() {
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.
+ DCHECK(create_trials_from_seed_called_);
+
// Perform the first fetch.
FetchVariationsSeed();
@@ -157,6 +164,10 @@
pending_seed_request_->SetRequestContext(
g_browser_process->system_request_context());
pending_seed_request_->SetMaxRetries(kMaxRetrySeedFetch);
+ if (!variations_serial_number_.empty()) {
+ pending_seed_request_->AddExtraRequestHeader("If-Match:" +
+ variations_serial_number_);
+ }
pending_seed_request_->Start();
}
@@ -169,9 +180,10 @@
DVLOG(1) << "Variations server request failed.";
return;
}
+
if (request->GetResponseCode() != 200) {
DVLOG(1) << "Variations server request returned non-200 response code: "
- << request->GetResponseCode();
+ << request->GetResponseCode();
return;
}
@@ -214,6 +226,7 @@
local_prefs->SetString(prefs::kVariationsSeed, base64_seed_data);
local_prefs->SetInt64(prefs::kVariationsSeedDate,
seed_date.ToInternalValue());
+ variations_serial_number_ = seed.serial_number();
return true;
}
@@ -415,6 +428,7 @@
local_prefs->ClearPref(prefs::kVariationsSeed);
return false;
}
+ variations_serial_number_ = seed->serial_number();
return true;
}
« chrome/browser/metrics/variations_service.h ('K') | « chrome/browser/metrics/variations_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698