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