15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/gtest_prod_util.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/memory/weak_ptr.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/metrics/field_trial.h" 15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/observer_list.h" 16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h" 17c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/metrics/variations/variations_request_scheduler.h" 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/metrics/variations/variations_seed_store.h" 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/web_resource/resource_request_allowed_notifier.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_version_info.h" 21116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/variations/variations_seed_simulator.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/url_request/url_fetcher_delegate.h" 23eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_WIN) 262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/metrics/variations/variations_registry_syncer_win.h" 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PrefService; 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PrefRegistrySimple; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)namespace base { 336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class Version; 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace metrics { 37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class MetricsStateManager; 38cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} 39cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)namespace user_prefs { 416d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class PrefRegistrySyncable; 426d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 436d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace variations { 4558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class VariationsSeed; 465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)} 475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace chrome_variations { 49424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Used to setup field trials based on stored variations seed data, and fetch 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// new seed data from the variations server. 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class VariationsService 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : public net::URLFetcherDelegate, 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public ResourceRequestAllowedNotifier::Observer { 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch class Observer { 57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch public: 58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // How critical a detected experiment change is. Whether it should be 59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // handled on a "best-effort" basis or, for a more critical change, if it 60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // should be given higher priority. 61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch enum Severity { 62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch BEST_EFFORT, 63116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch CRITICAL, 64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch }; 65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Called when the VariationsService detects that there will be significant 67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // experiment changes on a restart. This notification can then be used to 68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // update UI (i.e. badging an icon). 69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void OnExperimentChangesDetected(Severity severity) = 0; 70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch protected: 72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual ~Observer() {} 73116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch }; 74116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~VariationsService(); 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Creates field trials based on Variations Seed loaded from local prefs. If 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // there is a problem loading the seed data, all trials specified by the seed 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // may not be created. 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool CreateTrialsFromSeed(); 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Calls FetchVariationsSeed once and repeats this periodically. See 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // implementation for details on the period. Must be called after 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |CreateTrialsFromSeed|. 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StartRepeatedVariationsSeedFetch(); 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 87116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Adds an observer to listen for detected experiment changes. 88116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void AddObserver(Observer* observer); 89116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 90116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Removes a previously-added observer. 91116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void RemoveObserver(Observer* observer); 922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Called when the application enters foreground. This may trigger a 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // FetchVariationsSeed call. 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // TODO(rkaplow): Handle this and the similar event in metrics_service by 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // observing an 'OnAppEnterForeground' event instead of requiring the frontend 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // code to notify each service individually. 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void OnAppEnterForeground(); 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_WIN) 1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Starts syncing Google Update Variation IDs with the registry. 1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void StartGoogleUpdateRegistrySync(); 1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Exposed for testing. 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetCreateTrialsFromSeedCalledForTesting(bool called); 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 108116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Returns the variations server URL, which can vary if a command-line flag is 109116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // set and/or the variations restrict pref is set in |local_prefs|. Declared 110116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // static for test purposes. 111116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch static GURL GetVariationsServerURL(PrefService* local_prefs); 112116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Exposed for testing. 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static std::string GetDefaultVariationsServerURLForTesting(); 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Register Variations related prefs in Local State. 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static void RegisterPrefs(PrefRegistrySimple* registry); 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Register Variations related prefs in the Profile prefs. 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 122cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Factory method for creating a VariationsService. Does not take ownership of 123cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // |state_manager|. Caller should ensure that |state_manager| is valid for the 124cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // lifetime of this class. 125cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) static scoped_ptr<VariationsService> Create( 126cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PrefService* local_state, 127cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) metrics::MetricsStateManager* state_manager); 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set the PrefService responsible for getting policy-related preferences, 1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // such as the restrict parameter. 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void set_policy_pref_service(PrefService* service) { 1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DCHECK(service); 1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy_pref_service_ = service; 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Starts the fetching process once, where |OnURLFetchComplete| is called with 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the response. 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DoActualFetch(); 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Stores the seed to prefs. Set as virtual and protected so that it can be 142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // overridden by tests. 143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void StoreSeed(const std::string& seed_data, 144a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::string& seed_signature, 145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const base::Time& date_fetched); 146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 147116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Creates the VariationsService with the given |local_state| prefs service 148116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // and |state_manager|. This instance will take ownership of |notifier|. 149116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Does not take ownership of |state_manager|. Caller should ensure that 150116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // |state_manager| is valid for the lifetime of this class. Use the |Create| 151116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // factory method to create a VariationsService. 152c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) VariationsService(ResourceRequestAllowedNotifier* notifier, 153cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) PrefService* local_state, 154cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) metrics::MetricsStateManager* state_manager); 1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 157116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, Observer); 1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedStoredWhenOKStatus); 1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedNotStoredWhenNonOKStatus); 160f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(VariationsServiceTest, SeedDateUpdatedOn304Status); 1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Checks if prerequisites for fetching the Variations seed are met, and if 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // so, performs the actual fetch using |DoActualFetch|. 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void FetchVariationsSeed(); 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 166116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Notify any observers of this service based on the simulation |result|. 1675f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) void NotifyObservers( 1685f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) const variations::VariationsSeedSimulator::Result& result); 169116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // net::URLFetcherDelegate implementation: 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ResourceRequestAllowedNotifier::Observer implementation: 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnResourceRequestsAllowed() OVERRIDE; 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1766d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // Performs a variations seed simulation with the given |seed| and |version| 1776d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // and logs the simulation results as histograms. 1785f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) void PerformSimulationWithVersion(scoped_ptr<variations::VariationsSeed> seed, 1796d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const base::Version& version); 1806d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Record the time of the most recent successful fetch. 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void RecordLastFetchTime(); 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The pref service used to store persist the variations seed. 1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PrefService* local_state_; 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 187cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Used for instantiating entropy providers for variations seed simulation. 188cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Weak pointer. 189cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) metrics::MetricsStateManager* state_manager_; 190cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Used to obtain policy-related preferences. Depending on the platform, will 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // either be Local State or Profile prefs. 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) PrefService* policy_pref_service_; 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) VariationsSeedStore seed_store_; 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 197c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Contains the scheduler instance that handles timing for requests to the 198c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // server. Initially NULL and instantiated when the initial fetch is 199c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // requested. 200c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) scoped_ptr<VariationsRequestScheduler> request_scheduler_; 201c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Contains the current seed request. Will only have a value while a request 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is pending, and will be reset by |OnURLFetchComplete|. 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<net::URLFetcher> pending_seed_request_; 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The URL to use for querying the Variations server. 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL variations_server_url_; 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Tracks whether |CreateTrialsFromSeed| has been called, to ensure that 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it gets called prior to |StartRepeatedVariationsSeedFetch|. 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool create_trials_from_seed_called_; 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Tracks whether the initial request to the variations server had completed. 2147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) bool initial_request_completed_; 2157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Helper class used to tell this service if it's allowed to make network 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // resource requests. 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<ResourceRequestAllowedNotifier> resource_request_allowed_notifier_; 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The start time of the last seed request. This is used to measure the 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // latency of seed requests. Initially zero. 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::TimeTicks last_request_started_time_; 2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 224116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // List of observers of the VariationsService. 225116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch ObserverList<Observer> observer_list_; 226116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_WIN) 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Helper that handles synchronizing Variations with the Registry. 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) VariationsRegistrySyncer registry_syncer_; 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 231558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch 2326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) base::WeakPtrFactory<VariationsService> weak_ptr_factory_; 2336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 234558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch DISALLOW_COPY_AND_ASSIGN(VariationsService); 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace chrome_variations 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SERVICE_H_ 240