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

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 7467012: Modifying prefetch to account for multi-profile. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_impl_io_data.h" 5 #include "chrome/browser/profiles/profile_impl_io_data.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/browser/io_thread.h" 12 #include "chrome/browser/io_thread.h"
13 #include "chrome/browser/net/chrome_net_log.h" 13 #include "chrome/browser/net/chrome_net_log.h"
14 #include "chrome/browser/net/chrome_network_delegate.h" 14 #include "chrome/browser/net/chrome_network_delegate.h"
15 #include "chrome/browser/net/connect_interceptor.h"
16 #include "chrome/browser/net/predictor.h"
15 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" 17 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
16 #include "chrome/browser/prefs/pref_member.h" 18 #include "chrome/browser/prefs/pref_member.h"
17 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
22 #include "content/browser/browser_thread.h" 24 #include "content/browser/browser_thread.h"
23 #include "content/browser/resource_context.h" 25 #include "content/browser/resource_context.h"
24 #include "net/ftp/ftp_network_layer.h" 26 #include "net/ftp/ftp_network_layer.h"
25 #include "net/http/http_cache.h" 27 #include "net/http/http_cache.h"
28 #include "net/url_request/url_request_job_factory.h"
26 29
27 ProfileImplIOData::Handle::Handle(Profile* profile) 30 ProfileImplIOData::Handle::Handle(Profile* profile)
28 : io_data_(new ProfileImplIOData), 31 : io_data_(new ProfileImplIOData),
29 profile_(profile), 32 profile_(profile),
30 initialized_(false) { 33 initialized_(false) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 DCHECK(profile); 35 DCHECK(profile);
33 } 36 }
34 37
35 ProfileImplIOData::Handle::~Handle() { 38 ProfileImplIOData::Handle::~Handle() {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 if (main_request_context_getter_) 40 if (main_request_context_getter_)
38 main_request_context_getter_->CleanupOnUIThread(); 41 main_request_context_getter_->CleanupOnUIThread();
39 if (media_request_context_getter_) 42 if (media_request_context_getter_)
40 media_request_context_getter_->CleanupOnUIThread(); 43 media_request_context_getter_->CleanupOnUIThread();
41 if (extensions_request_context_getter_) 44 if (extensions_request_context_getter_)
42 extensions_request_context_getter_->CleanupOnUIThread(); 45 extensions_request_context_getter_->CleanupOnUIThread();
43 46
44 // Clean up all isolated app request contexts. 47 // Clean up all isolated app request contexts.
45 for (ChromeURLRequestContextGetterMap::iterator iter = 48 for (ChromeURLRequestContextGetterMap::iterator iter =
46 app_request_context_getter_map_.begin(); 49 app_request_context_getter_map_.begin();
47 iter != app_request_context_getter_map_.end(); 50 iter != app_request_context_getter_map_.end();
48 ++iter) { 51 ++iter) {
49 iter->second->CleanupOnUIThread(); 52 iter->second->CleanupOnUIThread();
50 } 53 }
51 54
52 io_data_->ShutdownOnUIThread(); 55 io_data_->ShutdownOnUIThread();
53 } 56 }
54 57
55 void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, 58 void ProfileImplIOData::Handle::Init(
56 const FilePath& cache_path, 59 const FilePath& cookie_path,
57 int cache_max_size, 60 const FilePath& cache_path,
58 const FilePath& media_cache_path, 61 int cache_max_size,
59 int media_cache_max_size, 62 const FilePath& media_cache_path,
60 const FilePath& extensions_cookie_path, 63 int media_cache_max_size,
61 const FilePath& app_path) { 64 const FilePath& extensions_cookie_path,
65 const FilePath& app_path,
66 chrome_browser_net::Predictor* predictor) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
63 DCHECK(!io_data_->lazy_params_.get()); 68 DCHECK(!io_data_->lazy_params_.get());
64 LazyParams* lazy_params = new LazyParams; 69 LazyParams* lazy_params = new LazyParams;
65 70
66 lazy_params->cookie_path = cookie_path; 71 lazy_params->cookie_path = cookie_path;
67 lazy_params->cache_path = cache_path; 72 lazy_params->cache_path = cache_path;
68 lazy_params->cache_max_size = cache_max_size; 73 lazy_params->cache_max_size = cache_max_size;
69 lazy_params->media_cache_path = media_cache_path; 74 lazy_params->media_cache_path = media_cache_path;
70 lazy_params->media_cache_max_size = media_cache_max_size; 75 lazy_params->media_cache_max_size = media_cache_max_size;
71 lazy_params->extensions_cookie_path = extensions_cookie_path; 76 lazy_params->extensions_cookie_path = extensions_cookie_path;
72 77
73 io_data_->lazy_params_.reset(lazy_params); 78 io_data_->lazy_params_.reset(lazy_params);
74 79
75 // Keep track of isolated app path separately so we can use it on demand. 80 // Keep track of isolated app path separately so we can use it on demand.
76 io_data_->app_path_ = app_path; 81 io_data_->app_path_ = app_path;
82
83 io_data_->predictor_.reset(predictor);
84 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs());
77 } 85 }
78 86
79 base::Callback<ChromeURLDataManagerBackend*(void)> 87 base::Callback<ChromeURLDataManagerBackend*(void)>
80 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { 88 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
82 LazyInitialize(); 90 LazyInitialize();
83 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, 91 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend,
84 base::Unretained(io_data_)); 92 base::Unretained(io_data_));
85 } 93 }
86 94
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 152
145 153
146 ChromeURLRequestContextGetter* context = 154 ChromeURLRequestContextGetter* context =
147 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( 155 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(
148 profile_, io_data_, app_id); 156 profile_, io_data_, app_id);
149 app_request_context_getter_map_[app_id] = context; 157 app_request_context_getter_map_[app_id] = context;
150 158
151 return context; 159 return context;
152 } 160 }
153 161
162 chrome_browser_net::Predictor*
163 ProfileImplIOData::Handle::GetNetworkPredictor() {
164 return io_data_->GetNetworkPredictor();
165 }
166
154 void ProfileImplIOData::Handle::LazyInitialize() const { 167 void ProfileImplIOData::Handle::LazyInitialize() const {
155 if (!initialized_) { 168 if (!initialized_) {
156 io_data_->InitializeProfileParams(profile_); 169 io_data_->InitializeProfileParams(profile_);
157 ChromeNetworkDelegate::InitializeReferrersEnabled( 170 ChromeNetworkDelegate::InitializeReferrersEnabled(
158 io_data_->enable_referrers(), profile_->GetPrefs()); 171 io_data_->enable_referrers(), profile_->GetPrefs());
159 io_data_->clear_local_state_on_exit()->Init( 172 io_data_->clear_local_state_on_exit()->Init(
160 prefs::kClearSiteDataOnExit, profile_->GetPrefs(), NULL); 173 prefs::kClearSiteDataOnExit, profile_->GetPrefs(), NULL);
161 io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO); 174 io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO);
162 #if defined(ENABLE_SAFE_BROWSING) 175 #if defined(ENABLE_SAFE_BROWSING)
163 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, 176 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 main_context->set_ftp_transaction_factory( 313 main_context->set_ftp_transaction_factory(
301 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); 314 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
302 315
303 main_context->set_chrome_url_data_manager_backend( 316 main_context->set_chrome_url_data_manager_backend(
304 chrome_url_data_manager_backend()); 317 chrome_url_data_manager_backend());
305 318
306 main_context->set_job_factory(job_factory()); 319 main_context->set_job_factory(job_factory());
307 media_request_context_->set_job_factory(job_factory()); 320 media_request_context_->set_job_factory(job_factory());
308 extensions_context->set_job_factory(job_factory()); 321 extensions_context->set_job_factory(job_factory());
309 322
323 job_factory()->AddInterceptor(
324 new chrome_browser_net::ConnectInterceptor(predictor_.get()));
325
310 lazy_params_.reset(); 326 lazy_params_.reset();
311 } 327 }
312 328
313 scoped_refptr<ChromeURLRequestContext> 329 scoped_refptr<ChromeURLRequestContext>
314 ProfileImplIOData::InitializeAppRequestContext( 330 ProfileImplIOData::InitializeAppRequestContext(
315 scoped_refptr<ChromeURLRequestContext> main_context, 331 scoped_refptr<ChromeURLRequestContext> main_context,
316 const std::string& app_id) const { 332 const std::string& app_id) const {
317 AppRequestContext* context = new AppRequestContext; 333 AppRequestContext* context = new AppRequestContext;
318 334
319 // Copy most state from the main context. 335 // Copy most state from the main context.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 scoped_refptr<ChromeURLRequestContext> 397 scoped_refptr<ChromeURLRequestContext>
382 ProfileImplIOData::AcquireIsolatedAppRequestContext( 398 ProfileImplIOData::AcquireIsolatedAppRequestContext(
383 scoped_refptr<ChromeURLRequestContext> main_context, 399 scoped_refptr<ChromeURLRequestContext> main_context,
384 const std::string& app_id) const { 400 const std::string& app_id) const {
385 // We create per-app contexts on demand, unlike the others above. 401 // We create per-app contexts on demand, unlike the others above.
386 scoped_refptr<ChromeURLRequestContext> app_request_context = 402 scoped_refptr<ChromeURLRequestContext> app_request_context =
387 InitializeAppRequestContext(main_context, app_id); 403 InitializeAppRequestContext(main_context, app_id);
388 DCHECK(app_request_context); 404 DCHECK(app_request_context);
389 return app_request_context; 405 return app_request_context;
390 } 406 }
407
408 chrome_browser_net::Predictor* ProfileImplIOData::GetNetworkPredictor() {
409 return predictor_.get();
410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698