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; |
} |