| OLD | NEW |
| 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" | |
| 8 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 12 #include "chrome/browser/io_thread.h" | 11 #include "chrome/browser/io_thread.h" |
| 13 #include "chrome/browser/net/chrome_net_log.h" | 12 #include "chrome/browser/net/chrome_net_log.h" |
| 14 #include "chrome/browser/net/chrome_network_delegate.h" | 13 #include "chrome/browser/net/chrome_network_delegate.h" |
| 15 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 14 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
| 16 #include "chrome/browser/prefs/pref_member.h" | 15 #include "chrome/browser/prefs/pref_member.h" |
| 17 #include "chrome/browser/profiles/profile.h" | |
| 18 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 22 #include "content/browser/browser_thread.h" | 20 #include "content/browser/browser_thread.h" |
| 23 #include "content/browser/resource_context.h" | 21 #include "content/browser/resource_context.h" |
| 24 #include "net/ftp/ftp_network_layer.h" | 22 #include "net/ftp/ftp_network_layer.h" |
| 25 #include "net/http/http_cache.h" | 23 #include "net/http/http_cache.h" |
| 26 | 24 |
| 27 ProfileImplIOData::Handle::Handle(Profile* profile) | 25 ProfileImplIOData::Handle::Handle(Profile* profile) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 42 extensions_request_context_getter_->CleanupOnUIThread(); | 40 extensions_request_context_getter_->CleanupOnUIThread(); |
| 43 | 41 |
| 44 // Clean up all isolated app request contexts. | 42 // Clean up all isolated app request contexts. |
| 45 for (ChromeURLRequestContextGetterMap::iterator iter = | 43 for (ChromeURLRequestContextGetterMap::iterator iter = |
| 46 app_request_context_getter_map_.begin(); | 44 app_request_context_getter_map_.begin(); |
| 47 iter != app_request_context_getter_map_.end(); | 45 iter != app_request_context_getter_map_.end(); |
| 48 ++iter) { | 46 ++iter) { |
| 49 iter->second->CleanupOnUIThread(); | 47 iter->second->CleanupOnUIThread(); |
| 50 } | 48 } |
| 51 | 49 |
| 52 io_data_.release()->ShutdownOnUIThread(); | 50 io_data_->ShutdownOnUIThread(); |
| 53 } | 51 } |
| 54 | 52 |
| 55 void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, | 53 void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, |
| 56 const FilePath& cache_path, | 54 const FilePath& cache_path, |
| 57 int cache_max_size, | 55 int cache_max_size, |
| 58 const FilePath& media_cache_path, | 56 const FilePath& media_cache_path, |
| 59 int media_cache_max_size, | 57 int media_cache_max_size, |
| 60 const FilePath& extensions_cookie_path, | 58 const FilePath& extensions_cookie_path, |
| 61 const FilePath& app_path) { | 59 const FilePath& app_path) { |
| 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 63 DCHECK(!io_data_->lazy_params_.get()); | 61 DCHECK(!io_data_->lazy_params_.get()); |
| 64 LazyParams* lazy_params = new LazyParams; | 62 LazyParams* lazy_params = new LazyParams; |
| 65 | 63 |
| 66 lazy_params->cookie_path = cookie_path; | 64 lazy_params->cookie_path = cookie_path; |
| 67 lazy_params->cache_path = cache_path; | 65 lazy_params->cache_path = cache_path; |
| 68 lazy_params->cache_max_size = cache_max_size; | 66 lazy_params->cache_max_size = cache_max_size; |
| 69 lazy_params->media_cache_path = media_cache_path; | 67 lazy_params->media_cache_path = media_cache_path; |
| 70 lazy_params->media_cache_max_size = media_cache_max_size; | 68 lazy_params->media_cache_max_size = media_cache_max_size; |
| 71 lazy_params->extensions_cookie_path = extensions_cookie_path; | 69 lazy_params->extensions_cookie_path = extensions_cookie_path; |
| 72 | 70 |
| 73 io_data_->lazy_params_.reset(lazy_params); | 71 io_data_->lazy_params_.reset(lazy_params); |
| 74 | 72 |
| 75 // Keep track of isolated app path separately so we can use it on demand. | 73 // Keep track of isolated app path separately so we can use it on demand. |
| 76 io_data_->app_path_ = app_path; | 74 io_data_->app_path_ = app_path; |
| 77 } | 75 } |
| 78 | 76 |
| 79 base::Callback<ChromeURLDataManagerBackend*(void)> | |
| 80 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { | |
| 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 82 LazyInitialize(); | |
| 83 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, | |
| 84 base::Unretained(io_data_.get())); | |
| 85 } | |
| 86 | |
| 87 const content::ResourceContext& | 77 const content::ResourceContext& |
| 88 ProfileImplIOData::Handle::GetResourceContext() const { | 78 ProfileImplIOData::Handle::GetResourceContext() const { |
| 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 90 // Don't call LazyInitialize here, since the resource context is created at | 80 // Don't call LazyInitialize here, since the resource context is created at |
| 91 // the beginning of initalization and is used by some members while they're | 81 // the beginning of initalization and is used by some members while they're |
| 92 // being initialized (i.e. AppCacheService). | 82 // being initialized (i.e. AppCacheService). |
| 93 return io_data_->GetResourceContext(); | 83 return io_data_->GetResourceContext(); |
| 94 } | 84 } |
| 95 | 85 |
| 96 scoped_refptr<ChromeURLRequestContextGetter> | 86 scoped_refptr<ChromeURLRequestContextGetter> |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 scoped_refptr<ProfileIOData::RequestContext> | 375 scoped_refptr<ProfileIOData::RequestContext> |
| 386 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 376 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 387 scoped_refptr<ChromeURLRequestContext> main_context, | 377 scoped_refptr<ChromeURLRequestContext> main_context, |
| 388 const std::string& app_id) const { | 378 const std::string& app_id) const { |
| 389 // We create per-app contexts on demand, unlike the others above. | 379 // We create per-app contexts on demand, unlike the others above. |
| 390 scoped_refptr<RequestContext> app_request_context = | 380 scoped_refptr<RequestContext> app_request_context = |
| 391 InitializeAppRequestContext(main_context, app_id); | 381 InitializeAppRequestContext(main_context, app_id); |
| 392 DCHECK(app_request_context); | 382 DCHECK(app_request_context); |
| 393 return app_request_context; | 383 return app_request_context; |
| 394 } | 384 } |
| OLD | NEW |