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

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

Issue 7685009: Revert "Modifying prefetch to account for multi-profile." (Closed) Base URL: svn://svn.chromium.org/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"
17 #include "chrome/browser/net/sqlite_origin_bound_cert_store.h" 15 #include "chrome/browser/net/sqlite_origin_bound_cert_store.h"
18 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" 16 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
19 #include "chrome/browser/prefs/pref_member.h" 17 #include "chrome/browser/prefs/pref_member.h"
20 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
22 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
25 #include "content/browser/browser_thread.h" 23 #include "content/browser/browser_thread.h"
26 #include "content/browser/resource_context.h" 24 #include "content/browser/resource_context.h"
27 #include "net/base/origin_bound_cert_service.h" 25 #include "net/base/origin_bound_cert_service.h"
28 #include "net/ftp/ftp_network_layer.h" 26 #include "net/ftp/ftp_network_layer.h"
29 #include "net/http/http_cache.h" 27 #include "net/http/http_cache.h"
30 #include "net/url_request/url_request_job_factory.h"
31 28
32 ProfileImplIOData::Handle::Handle(Profile* profile) 29 ProfileImplIOData::Handle::Handle(Profile* profile)
33 : io_data_(new ProfileImplIOData), 30 : io_data_(new ProfileImplIOData),
34 profile_(profile), 31 profile_(profile),
35 initialized_(false) { 32 initialized_(false) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 DCHECK(profile); 34 DCHECK(profile);
38 } 35 }
39 36
40 ProfileImplIOData::Handle::~Handle() { 37 ProfileImplIOData::Handle::~Handle() {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
42 if (main_request_context_getter_) 39 if (main_request_context_getter_)
43 main_request_context_getter_->CleanupOnUIThread(); 40 main_request_context_getter_->CleanupOnUIThread();
44 if (media_request_context_getter_) 41 if (media_request_context_getter_)
45 media_request_context_getter_->CleanupOnUIThread(); 42 media_request_context_getter_->CleanupOnUIThread();
46 if (extensions_request_context_getter_) 43 if (extensions_request_context_getter_)
47 extensions_request_context_getter_->CleanupOnUIThread(); 44 extensions_request_context_getter_->CleanupOnUIThread();
48 45
49 io_data_->predictor_->ShutdownOnUIThread(profile_->GetPrefs());
50
51 // Clean up all isolated app request contexts. 46 // Clean up all isolated app request contexts.
52 for (ChromeURLRequestContextGetterMap::iterator iter = 47 for (ChromeURLRequestContextGetterMap::iterator iter =
53 app_request_context_getter_map_.begin(); 48 app_request_context_getter_map_.begin();
54 iter != app_request_context_getter_map_.end(); 49 iter != app_request_context_getter_map_.end();
55 ++iter) { 50 ++iter) {
56 iter->second->CleanupOnUIThread(); 51 iter->second->CleanupOnUIThread();
57 } 52 }
58 53
59 io_data_->ShutdownOnUIThread(); 54 io_data_->ShutdownOnUIThread();
60 } 55 }
61 56
62 void ProfileImplIOData::Handle::Init( 57 void ProfileImplIOData::Handle::Init(const FilePath& cookie_path,
63 const FilePath& cookie_path, 58 const FilePath& origin_bound_cert_path,
64 const FilePath& origin_bound_cert_path, 59 const FilePath& cache_path,
65 const FilePath& cache_path, 60 int cache_max_size,
66 int cache_max_size, 61 const FilePath& media_cache_path,
67 const FilePath& media_cache_path, 62 int media_cache_max_size,
68 int media_cache_max_size, 63 const FilePath& extensions_cookie_path,
69 const FilePath& extensions_cookie_path, 64 const FilePath& app_path) {
70 const FilePath& app_path,
71 chrome_browser_net::Predictor* predictor,
72 PrefService* local_state,
73 IOThread* io_thread) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
75 DCHECK(!io_data_->lazy_params_.get()); 66 DCHECK(!io_data_->lazy_params_.get());
76 DCHECK(predictor);
77
78 LazyParams* lazy_params = new LazyParams; 67 LazyParams* lazy_params = new LazyParams;
79 68
80 lazy_params->cookie_path = cookie_path; 69 lazy_params->cookie_path = cookie_path;
81 lazy_params->origin_bound_cert_path = origin_bound_cert_path; 70 lazy_params->origin_bound_cert_path = origin_bound_cert_path;
82 lazy_params->cache_path = cache_path; 71 lazy_params->cache_path = cache_path;
83 lazy_params->cache_max_size = cache_max_size; 72 lazy_params->cache_max_size = cache_max_size;
84 lazy_params->media_cache_path = media_cache_path; 73 lazy_params->media_cache_path = media_cache_path;
85 lazy_params->media_cache_max_size = media_cache_max_size; 74 lazy_params->media_cache_max_size = media_cache_max_size;
86 lazy_params->extensions_cookie_path = extensions_cookie_path; 75 lazy_params->extensions_cookie_path = extensions_cookie_path;
87 76
88 io_data_->lazy_params_.reset(lazy_params); 77 io_data_->lazy_params_.reset(lazy_params);
89 78
90 // Keep track of isolated app path separately so we can use it on demand. 79 // Keep track of isolated app path separately so we can use it on demand.
91 io_data_->app_path_ = app_path; 80 io_data_->app_path_ = app_path;
92
93 io_data_->predictor_.reset(predictor);
94 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(),
95 local_state,
96 io_thread);
97 } 81 }
98 82
99 base::Callback<ChromeURLDataManagerBackend*(void)> 83 base::Callback<ChromeURLDataManagerBackend*(void)>
100 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { 84 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const {
101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
102 LazyInitialize(); 86 LazyInitialize();
103 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, 87 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend,
104 base::Unretained(io_data_)); 88 base::Unretained(io_data_));
105 } 89 }
106 90
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 main_context->set_ftp_transaction_factory( 329 main_context->set_ftp_transaction_factory(
346 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); 330 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
347 331
348 main_context->set_chrome_url_data_manager_backend( 332 main_context->set_chrome_url_data_manager_backend(
349 chrome_url_data_manager_backend()); 333 chrome_url_data_manager_backend());
350 334
351 main_context->set_job_factory(job_factory()); 335 main_context->set_job_factory(job_factory());
352 media_request_context_->set_job_factory(job_factory()); 336 media_request_context_->set_job_factory(job_factory());
353 extensions_context->set_job_factory(job_factory()); 337 extensions_context->set_job_factory(job_factory());
354 338
355 job_factory()->AddInterceptor(
356 new chrome_browser_net::ConnectInterceptor(predictor_.get()));
357
358 lazy_params_.reset(); 339 lazy_params_.reset();
359 } 340 }
360 341
361 scoped_refptr<ChromeURLRequestContext> 342 scoped_refptr<ChromeURLRequestContext>
362 ProfileImplIOData::InitializeAppRequestContext( 343 ProfileImplIOData::InitializeAppRequestContext(
363 scoped_refptr<ChromeURLRequestContext> main_context, 344 scoped_refptr<ChromeURLRequestContext> main_context,
364 const std::string& app_id) const { 345 const std::string& app_id) const {
365 AppRequestContext* context = new AppRequestContext; 346 AppRequestContext* context = new AppRequestContext;
366 347
367 // Copy most state from the main context. 348 // Copy most state from the main context.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 scoped_refptr<ChromeURLRequestContext> 410 scoped_refptr<ChromeURLRequestContext>
430 ProfileImplIOData::AcquireIsolatedAppRequestContext( 411 ProfileImplIOData::AcquireIsolatedAppRequestContext(
431 scoped_refptr<ChromeURLRequestContext> main_context, 412 scoped_refptr<ChromeURLRequestContext> main_context,
432 const std::string& app_id) const { 413 const std::string& app_id) const {
433 // We create per-app contexts on demand, unlike the others above. 414 // We create per-app contexts on demand, unlike the others above.
434 scoped_refptr<ChromeURLRequestContext> app_request_context = 415 scoped_refptr<ChromeURLRequestContext> app_request_context =
435 InitializeAppRequestContext(main_context, app_id); 416 InitializeAppRequestContext(main_context, app_id);
436 DCHECK(app_request_context); 417 DCHECK(app_request_context);
437 return app_request_context; 418 return app_request_context;
438 } 419 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.h ('k') | chrome/browser/renderer_host/chrome_render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698