summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles
diff options
context:
space:
mode:
authorrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-10 01:30:46 +0000
committerrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-10 01:30:46 +0000
commit67372ecfa788fa29193f94029f9eccac2c08af0f (patch)
treee99301edd0e3b874600d3fbcdede208e35adcbdb /chrome/browser/profiles
parent29adff69903acfae6aca00ba41b185d143f57f35 (diff)
downloadchromium_src-67372ecfa788fa29193f94029f9eccac2c08af0f.zip
chromium_src-67372ecfa788fa29193f94029f9eccac2c08af0f.tar.gz
chromium_src-67372ecfa788fa29193f94029f9eccac2c08af0f.tar.bz2
Modifying prefetch to account for multi-profile.
Items of note: - predictor_api is gone. Most functions in predictor_api.cc have moved into the chrome_browser_net::Predictor class or the Profile class. - The predictor state is cleaned up in the Profile dtor. - Predictor is owned by the ProfileIOData of the profile. - InitialObserver class is gone since each profile keeps their own info, the non-OTR don't care if anyone is OTR. - Predictor is created by the profile and then passed to the ProfileIOData. Then its initialization is finished on the IOThread. - ConnectInterceptor now subclasses off of UrlRequestJobFactory::Interceptor. - Updated Profile to create a SimpleShutdownPredictor with limited functionality when in unittests. BUG=89937,90114 TEST=passes existing Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=97446 Review URL: http://codereview.chromium.org/7467012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r--chrome/browser/profiles/profile.cc4
-rw-r--r--chrome/browser/profiles/profile.h6
-rw-r--r--chrome/browser/profiles/profile_impl.cc22
-rw-r--r--chrome/browser/profiles/profile_impl.h3
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc35
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.h11
6 files changed, 69 insertions, 12 deletions
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 22d1e85..23b24d3 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -225,3 +225,7 @@ bool Profile::IsSyncAccessible() {
ProfileSyncService* syncService = GetProfileSyncService();
return syncService && !syncService->IsManaged();
}
+
+chrome_browser_net::Predictor* Profile::GetNetworkPredictor() {
+ return NULL;
+}
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index c2ba480..2cd49e4 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -52,6 +52,10 @@ namespace speech_input {
class SpeechRecognizer;
}
+namespace chrome_browser_net {
+class Predictor;
+}
+
class AutocompleteClassifier;
class BookmarkModel;
class ChromeAppCacheService;
@@ -543,6 +547,8 @@ class Profile : public content::BrowserContext {
// Creates an OffTheRecordProfile which points to this Profile.
Profile* CreateOffTheRecordProfile();
+ virtual chrome_browser_net::Predictor* GetNetworkPredictor();
+
protected:
friend class OffTheRecordProfileImpl;
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 02a9374..af5435f 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -47,6 +47,7 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/net/net_pref_observer.h"
+#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/pref_proxy_config_service.h"
#include "chrome/browser/net/ssl_config_service_manager.h"
#include "chrome/browser/password_manager/password_store_default.h"
@@ -308,7 +309,8 @@ ProfileImpl::ProfileImpl(const FilePath& path,
#if defined(OS_WIN)
checked_instant_promo_(false),
#endif
- delegate_(delegate) {
+ delegate_(delegate),
+ predictor_(NULL) {
DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
"profile files to the root directory!";
@@ -316,6 +318,13 @@ ProfileImpl::ProfileImpl(const FilePath& path,
TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
&ProfileImpl::EnsureSessionServiceCreated);
+ // Determine if prefetch is enabled for this profile.
+ // If not profile_manager is present, it means we are in a unittest.
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ predictor_ = chrome_browser_net::Predictor::CreatePredictor(
+ !command_line->HasSwitch(switches::kDisablePreconnect),
+ g_browser_process->profile_manager() == NULL);
+
if (delegate_) {
prefs_.reset(PrefService::CreatePrefService(
GetPrefFilePath(),
@@ -436,9 +445,12 @@ void ProfileImpl::DoFinalInit() {
// Make sure we initialize the ProfileIOData after everything else has been
// initialized that we might be reading from the IO thread.
+
io_data_.Init(cookie_path, origin_bound_cert_path, cache_path,
cache_max_size, media_cache_path, media_cache_max_size,
- extensions_cookie_path, app_path);
+ extensions_cookie_path, app_path, predictor_,
+ g_browser_process->local_state(),
+ g_browser_process->io_thread());
ChromePluginServiceFilter::GetInstance()->RegisterResourceContext(
PluginPrefs::GetForProfile(this), &GetResourceContext());
@@ -922,7 +934,7 @@ void ProfileImpl::OnPrefsLoaded(bool success) {
DCHECK(!net_pref_observer_.get());
net_pref_observer_.reset(
- new NetPrefObserver(prefs_.get(), GetPrerenderManager()));
+ new NetPrefObserver(prefs_.get(), GetPrerenderManager(), predictor_));
DoFinalInit();
}
@@ -1739,6 +1751,10 @@ prerender::PrerenderManager* ProfileImpl::GetPrerenderManager() {
return prerender_manager_.get();
}
+chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() {
+ return predictor_;
+}
+
SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() {
if (!spellcheck_profile_.get())
spellcheck_profile_.reset(new SpellCheckProfile());
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index cdc2985..850b421 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -122,6 +122,7 @@ class ProfileImpl : public Profile,
virtual ExtensionInfoMap* GetExtensionInfoMap();
virtual PromoCounter* GetInstantPromoCounter();
virtual ChromeURLDataManager* GetChromeURLDataManager();
+ virtual chrome_browser_net::Predictor* GetNetworkPredictor();
#if defined(OS_CHROMEOS)
virtual void ChangeAppLocale(const std::string& locale, AppLocaleChangedVia);
@@ -290,6 +291,8 @@ class ProfileImpl : public Profile,
Profile::Delegate* delegate_;
+ chrome_browser_net::Predictor* predictor_;
+
DISALLOW_COPY_AND_ASSIGN(ProfileImpl);
};
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index 8ef2f4a..c523c25 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -12,6 +12,8 @@
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/chrome_network_delegate.h"
+#include "chrome/browser/net/connect_interceptor.h"
+#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/sqlite_origin_bound_cert_store.h"
#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
#include "chrome/browser/prefs/pref_member.h"
@@ -25,6 +27,7 @@
#include "net/base/origin_bound_cert_service.h"
#include "net/ftp/ftp_network_layer.h"
#include "net/http/http_cache.h"
+#include "net/url_request/url_request_job_factory.h"
ProfileImplIOData::Handle::Handle(Profile* profile)
: io_data_(new ProfileImplIOData),
@@ -43,6 +46,8 @@ ProfileImplIOData::Handle::~Handle() {
if (extensions_request_context_getter_)
extensions_request_context_getter_->CleanupOnUIThread();
+ io_data_->predictor_->ShutdownOnUIThread(profile_->GetPrefs());
+
// Clean up all isolated app request contexts.
for (ChromeURLRequestContextGetterMap::iterator iter =
app_request_context_getter_map_.begin();
@@ -54,16 +59,22 @@ ProfileImplIOData::Handle::~Handle() {
io_data_->ShutdownOnUIThread();
}
-void ProfileImplIOData::Handle::Init(const FilePath& cookie_path,
- const FilePath& origin_bound_cert_path,
- const FilePath& cache_path,
- int cache_max_size,
- const FilePath& media_cache_path,
- int media_cache_max_size,
- const FilePath& extensions_cookie_path,
- const FilePath& app_path) {
+void ProfileImplIOData::Handle::Init(
+ const FilePath& cookie_path,
+ const FilePath& origin_bound_cert_path,
+ const FilePath& cache_path,
+ int cache_max_size,
+ const FilePath& media_cache_path,
+ int media_cache_max_size,
+ const FilePath& extensions_cookie_path,
+ const FilePath& app_path,
+ chrome_browser_net::Predictor* predictor,
+ PrefService* local_state,
+ IOThread* io_thread) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!io_data_->lazy_params_.get());
+ DCHECK(predictor);
+
LazyParams* lazy_params = new LazyParams;
lazy_params->cookie_path = cookie_path;
@@ -78,6 +89,11 @@ void ProfileImplIOData::Handle::Init(const FilePath& cookie_path,
// Keep track of isolated app path separately so we can use it on demand.
io_data_->app_path_ = app_path;
+
+ io_data_->predictor_.reset(predictor);
+ io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(),
+ local_state,
+ io_thread);
}
base::Callback<ChromeURLDataManagerBackend*(void)>
@@ -336,6 +352,9 @@ void ProfileImplIOData::LazyInitializeInternal(
media_request_context_->set_job_factory(job_factory());
extensions_context->set_job_factory(job_factory());
+ job_factory()->AddInterceptor(
+ new chrome_browser_net::ConnectInterceptor(predictor_.get()));
+
lazy_params_.reset();
}
diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h
index 6a5f531..e0f61ff 100644
--- a/chrome/browser/profiles/profile_impl_io_data.h
+++ b/chrome/browser/profiles/profile_impl_io_data.h
@@ -12,6 +12,10 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/profiles/profile_io_data.h"
+namespace chrome_browser_net {
+class Predictor;
+}
+
namespace net {
class HttpTransactionFactory;
} // namespace net
@@ -36,7 +40,10 @@ class ProfileImplIOData : public ProfileIOData {
const FilePath& media_cache_path,
int media_cache_max_size,
const FilePath& extensions_cookie_path,
- const FilePath& app_path);
+ const FilePath& app_path,
+ chrome_browser_net::Predictor* predictor,
+ PrefService* local_state,
+ IOThread* io_thread);
base::Callback<ChromeURLDataManagerBackend*(void)>
GetChromeURLDataManagerBackendGetter() const;
@@ -127,6 +134,8 @@ class ProfileImplIOData : public ProfileIOData {
mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
mutable scoped_ptr<net::HttpTransactionFactory> media_http_factory_;
+ mutable scoped_ptr<chrome_browser_net::Predictor> predictor_;
+
// Parameters needed for isolated apps.
FilePath app_path_;
mutable bool clear_local_state_on_exit_;