Chromium Code Reviews| Index: chrome/browser/net/predictor.h |
| diff --git a/chrome/browser/net/predictor.h b/chrome/browser/net/predictor.h |
| index bac4ca9e6e0a6615cdef3bdc4f582a1117077b96..2852dad48bbf6bf033191d79aa523e0c1ecb0d6d 100644 |
| --- a/chrome/browser/net/predictor.h |
| +++ b/chrome/browser/net/predictor.h |
| @@ -38,6 +38,7 @@ |
| class IOThread; |
| class PrefService; |
| class Profile; |
| +class ProfileIOData; |
| namespace base { |
| class ListValue; |
| @@ -115,13 +116,14 @@ class Predictor { |
| // |max_concurrent| specifies how many concurrent (parallel) prefetches will |
| // be performed. Host lookups will be issued through |host_resolver|. |
| - explicit Predictor(bool preconnect_enabled); |
| + explicit Predictor(bool preconnect_enabled, bool predictor_enabled); |
| virtual ~Predictor(); |
| // This function is used to create a predictor. For testing, we can create |
| // a version which does a simpler shutdown. |
| static Predictor* CreatePredictor(bool preconnect_enabled, |
| + bool predictor_enabled, |
| bool simple_shutdown); |
| static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| @@ -131,7 +133,8 @@ class Predictor { |
| virtual void InitNetworkPredictor(PrefService* user_prefs, |
| PrefService* local_state, |
| IOThread* io_thread, |
| - net::URLRequestContextGetter* getter); |
| + net::URLRequestContextGetter* getter, |
| + ProfileIOData* profile_io_data); |
| // The Omnibox has proposed a given url to the user, and if it is a search |
| // URL, then it also indicates that this is preconnectable (i.e., we could |
| @@ -212,7 +215,7 @@ class Predictor { |
| const std::vector<GURL>& urls_to_prefetch, |
| base::ListValue* referral_list, |
| IOThread* io_thread, |
| - bool predictor_enabled); |
| + ProfileIOData* profile_io_data); |
| // During startup, we learn what the first N urls visited are, and then |
| // resolve the associated hosts ASAP during our next startup. |
| @@ -229,7 +232,7 @@ class Predictor { |
| // May be called from either the IO or UI thread and will PostTask |
| // to the IO thread if necessary. |
| - void SaveStateForNextStartupAndTrim(PrefService* prefs); |
| + void SaveStateForNextStartupAndTrim(); |
| void SaveDnsPrefetchStateForNextStartupAndTrim( |
| base::ListValue* startup_list, |
| @@ -238,12 +241,6 @@ class Predictor { |
| // May be called from either the IO or UI thread and will PostTask |
| // to the IO thread if necessary. |
| - void EnablePredictor(bool enable); |
| - |
| - void EnablePredictorOnIOThread(bool enable); |
| - |
| - // May be called from either the IO or UI thread and will PostTask |
| - // to the IO thread if necessary. |
| void PreconnectUrl(const GURL& url, const GURL& first_party_for_cookies, |
| UrlInfo::ResolutionMotivation motivation, int count); |
| @@ -295,12 +292,14 @@ class Predictor { |
| observer_ = observer; |
| } |
| - // Flag setting to use preconnection instead of just DNS pre-fetching. |
| + ProfileIOData* profile_io_data() const { |
| + return profile_io_data_; |
| + } |
| + |
| bool preconnect_enabled() const { |
| return preconnect_enabled_; |
| } |
| - // Flag setting for whether we are prefetching dns lookups. |
| bool predictor_enabled() const { |
| return predictor_enabled_; |
| } |
| @@ -508,8 +507,16 @@ class Predictor { |
| scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| // Status of speculative DNS resolution and speculative TCP/IP connection |
| - // feature. |
| - bool predictor_enabled_; |
| + // feature. This is false if and only if disabled by a command line switch. |
| + const bool predictor_enabled_; |
|
battre
2014/07/01 08:27:48
This is a little bit strange in my opinion, becaus
|
| + |
| + // This is set by InitNetworkPredictor and used for calling |
| + // chrome_browser_net::CanPredictNetworkActionsUI. |
| + PrefService* user_prefs_; |
| + |
| + // This is set by InitNetworkPredictor and used for calling |
| + // chrome_browser_net::CanPredictNetworkActionsIO. |
| + ProfileIOData* profile_io_data_; |
| // work_queue_ holds a list of names we need to look up. |
| HostNameQueue work_queue_; |
| @@ -547,7 +554,8 @@ class Predictor { |
| // Are we currently using preconnection, rather than just DNS resolution, for |
| // subresources and omni-box search URLs. |
| - bool preconnect_enabled_; |
| + // This is false if and only if disabled by a command line switch. |
| + const bool preconnect_enabled_; |
| // Most recent suggestion from Omnibox provided via AnticipateOmniboxUrl(). |
| std::string last_omnibox_host_; |
| @@ -588,14 +596,15 @@ class Predictor { |
| // This version of the predictor is used for testing. |
| class SimplePredictor : public Predictor { |
| public: |
| - explicit SimplePredictor(bool preconnect_enabled) |
| - : Predictor(preconnect_enabled) {} |
| + explicit SimplePredictor(bool preconnect_enabled, bool predictor_enabled) |
| + : Predictor(preconnect_enabled, predictor_enabled) {} |
| virtual ~SimplePredictor() {} |
| virtual void InitNetworkPredictor( |
| PrefService* user_prefs, |
| PrefService* local_state, |
| IOThread* io_thread, |
| - net::URLRequestContextGetter* getter) OVERRIDE; |
| + net::URLRequestContextGetter* getter, |
| + ProfileIOData* profile_io_data) OVERRIDE; |
| virtual void ShutdownOnUIThread() OVERRIDE; |
| }; |