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