| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 25 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
| 26 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 33 #include "content/public/browser/resource_context.h" | 33 #include "content/public/browser/resource_context.h" |
| 34 #include "content/public/browser/storage_partition.h" |
| 34 #include "net/base/server_bound_cert_service.h" | 35 #include "net/base/server_bound_cert_service.h" |
| 35 #include "net/ftp/ftp_network_layer.h" | 36 #include "net/ftp/ftp_network_layer.h" |
| 36 #include "net/http/http_cache.h" | 37 #include "net/http/http_cache.h" |
| 37 #include "net/url_request/file_protocol_handler.h" | 38 #include "net/url_request/file_protocol_handler.h" |
| 38 #include "net/url_request/ftp_protocol_handler.h" | 39 #include "net/url_request/ftp_protocol_handler.h" |
| 39 #include "net/url_request/url_request_job_factory_impl.h" | 40 #include "net/url_request/url_request_job_factory_impl.h" |
| 40 #include "webkit/quota/special_storage_policy.h" | 41 #include "webkit/quota/special_storage_policy.h" |
| 41 | 42 |
| 42 using content::BrowserThread; | 43 using content::BrowserThread; |
| 43 | 44 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 88 } |
| 88 | 89 |
| 89 void ProfileImplIOData::Handle::Init( | 90 void ProfileImplIOData::Handle::Init( |
| 90 const FilePath& cookie_path, | 91 const FilePath& cookie_path, |
| 91 const FilePath& server_bound_cert_path, | 92 const FilePath& server_bound_cert_path, |
| 92 const FilePath& cache_path, | 93 const FilePath& cache_path, |
| 93 int cache_max_size, | 94 int cache_max_size, |
| 94 const FilePath& media_cache_path, | 95 const FilePath& media_cache_path, |
| 95 int media_cache_max_size, | 96 int media_cache_max_size, |
| 96 const FilePath& extensions_cookie_path, | 97 const FilePath& extensions_cookie_path, |
| 97 const FilePath& app_path, | 98 const FilePath& profile_path, |
| 98 const FilePath& infinite_cache_path, | 99 const FilePath& infinite_cache_path, |
| 99 chrome_browser_net::Predictor* predictor, | 100 chrome_browser_net::Predictor* predictor, |
| 100 PrefService* local_state, | 101 PrefService* local_state, |
| 101 IOThread* io_thread, | 102 IOThread* io_thread, |
| 102 bool restore_old_session_cookies, | 103 bool restore_old_session_cookies, |
| 103 quota::SpecialStoragePolicy* special_storage_policy) { | 104 quota::SpecialStoragePolicy* special_storage_policy) { |
| 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 105 DCHECK(!io_data_->lazy_params_.get()); | 106 DCHECK(!io_data_->lazy_params_.get()); |
| 106 DCHECK(predictor); | 107 DCHECK(predictor); |
| 107 | 108 |
| 108 LazyParams* lazy_params = new LazyParams; | 109 LazyParams* lazy_params = new LazyParams; |
| 109 | 110 |
| 110 lazy_params->cookie_path = cookie_path; | 111 lazy_params->cookie_path = cookie_path; |
| 111 lazy_params->server_bound_cert_path = server_bound_cert_path; | 112 lazy_params->server_bound_cert_path = server_bound_cert_path; |
| 112 lazy_params->cache_path = cache_path; | 113 lazy_params->cache_path = cache_path; |
| 113 lazy_params->cache_max_size = cache_max_size; | 114 lazy_params->cache_max_size = cache_max_size; |
| 114 lazy_params->media_cache_path = media_cache_path; | 115 lazy_params->media_cache_path = media_cache_path; |
| 115 lazy_params->media_cache_max_size = media_cache_max_size; | 116 lazy_params->media_cache_max_size = media_cache_max_size; |
| 116 lazy_params->extensions_cookie_path = extensions_cookie_path; | 117 lazy_params->extensions_cookie_path = extensions_cookie_path; |
| 117 lazy_params->infinite_cache_path = infinite_cache_path; | 118 lazy_params->infinite_cache_path = infinite_cache_path; |
| 118 lazy_params->restore_old_session_cookies = restore_old_session_cookies; | 119 lazy_params->restore_old_session_cookies = restore_old_session_cookies; |
| 119 lazy_params->special_storage_policy = special_storage_policy; | 120 lazy_params->special_storage_policy = special_storage_policy; |
| 120 | 121 |
| 121 io_data_->lazy_params_.reset(lazy_params); | 122 io_data_->lazy_params_.reset(lazy_params); |
| 122 | 123 |
| 123 // Keep track of isolated app path and cache sizes separately so we can use | 124 // Keep track of profile path and cache sizes separately so we can use them |
| 124 // them on demand. | 125 // on demand when creating storage isolated URLRequestContextGetters. |
| 125 io_data_->app_path_ = app_path; | 126 io_data_->profile_path_ = profile_path; |
| 126 io_data_->app_cache_max_size_ = cache_max_size; | 127 io_data_->app_cache_max_size_ = cache_max_size; |
| 127 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 128 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
| 128 | 129 |
| 129 io_data_->predictor_.reset(predictor); | 130 io_data_->predictor_.reset(predictor); |
| 130 | 131 |
| 131 if (!main_request_context_getter_) { | 132 if (!main_request_context_getter_) { |
| 132 main_request_context_getter_ = | 133 main_request_context_getter_ = |
| 133 ChromeURLRequestContextGetter::CreateOriginal( | 134 ChromeURLRequestContextGetter::CreateOriginal( |
| 134 profile_, io_data_); | 135 profile_, io_data_); |
| 135 } | 136 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 ChromeURLRequestContext* main_context, | 504 ChromeURLRequestContext* main_context, |
| 504 const std::string& app_id) const { | 505 const std::string& app_id) const { |
| 505 // If this is for a guest process, we should not persist cookies and http | 506 // If this is for a guest process, we should not persist cookies and http |
| 506 // cache. | 507 // cache. |
| 507 bool is_guest_process = (app_id.find("guest-") != std::string::npos); | 508 bool is_guest_process = (app_id.find("guest-") != std::string::npos); |
| 508 | 509 |
| 509 // Copy most state from the main context. | 510 // Copy most state from the main context. |
| 510 AppRequestContext* context = new AppRequestContext(load_time_stats()); | 511 AppRequestContext* context = new AppRequestContext(load_time_stats()); |
| 511 context->CopyFrom(main_context); | 512 context->CopyFrom(main_context); |
| 512 | 513 |
| 513 FilePath app_path = app_path_.AppendASCII(app_id); | 514 using content::StoragePartition; |
| 515 FilePath app_path = |
| 516 profile_path_.Append(StoragePartition::GetPartitionPath(app_id)); |
| 517 |
| 514 FilePath cookie_path = app_path.Append(chrome::kCookieFilename); | 518 FilePath cookie_path = app_path.Append(chrome::kCookieFilename); |
| 515 FilePath cache_path = app_path.Append(chrome::kCacheDirname); | 519 FilePath cache_path = app_path.Append(chrome::kCacheDirname); |
| 516 | 520 |
| 517 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 521 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 518 // Only allow Record Mode if we are in a Debug build or where we are running | 522 // Only allow Record Mode if we are in a Debug build or where we are running |
| 519 // a cycle, and the user has limited control. | 523 // a cycle, and the user has limited control. |
| 520 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && | 524 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && |
| 521 (chrome::kRecordModeEnabled || | 525 (chrome::kRecordModeEnabled || |
| 522 command_line.HasSwitch(switches::kVisitURLs)); | 526 command_line.HasSwitch(switches::kVisitURLs)); |
| 523 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 527 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 const std::string& app_id) const { | 580 const std::string& app_id) const { |
| 577 // If this is for a guest process, we do not persist storage, so we can | 581 // If this is for a guest process, we do not persist storage, so we can |
| 578 // simply use the app's in-memory cache (like off-the-record mode). | 582 // simply use the app's in-memory cache (like off-the-record mode). |
| 579 if (app_id.find("guest-") != std::string::npos) | 583 if (app_id.find("guest-") != std::string::npos) |
| 580 return original_context; | 584 return original_context; |
| 581 | 585 |
| 582 // Copy most state from the original context. | 586 // Copy most state from the original context. |
| 583 MediaRequestContext* context = new MediaRequestContext(load_time_stats()); | 587 MediaRequestContext* context = new MediaRequestContext(load_time_stats()); |
| 584 context->CopyFrom(original_context); | 588 context->CopyFrom(original_context); |
| 585 | 589 |
| 586 FilePath app_path = app_path_.AppendASCII(app_id); | 590 using content::StoragePartition; |
| 591 FilePath app_path = |
| 592 profile_path_.Append(StoragePartition::GetPartitionPath(app_id)); |
| 587 FilePath cache_path; | 593 FilePath cache_path; |
| 588 int cache_max_size = app_media_cache_max_size_; | 594 int cache_max_size = app_media_cache_max_size_; |
| 589 if (app_id.empty()) { | 595 if (app_id.empty()) { |
| 590 // lazy_params_ is only valid for the default media context creation. | 596 // lazy_params_ is only valid for the default media context creation. |
| 591 cache_path = lazy_params_->media_cache_path; | 597 cache_path = lazy_params_->media_cache_path; |
| 592 cache_max_size = lazy_params_->media_cache_max_size; | 598 cache_max_size = lazy_params_->media_cache_max_size; |
| 593 } else { | 599 } else { |
| 594 cache_path = app_path.Append(chrome::kMediaCacheDirname); | 600 cache_path = app_path.Append(chrome::kMediaCacheDirname); |
| 595 } | 601 } |
| 596 | 602 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 665 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 660 base::Time time) { | 666 base::Time time) { |
| 661 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 662 LazyInitialize(); | 668 LazyInitialize(); |
| 663 | 669 |
| 664 DCHECK(transport_security_state()); | 670 DCHECK(transport_security_state()); |
| 665 transport_security_state()->DeleteSince(time); | 671 transport_security_state()->DeleteSince(time); |
| 666 DCHECK(http_server_properties_manager()); | 672 DCHECK(http_server_properties_manager()); |
| 667 http_server_properties_manager()->Clear(); | 673 http_server_properties_manager()->Clear(); |
| 668 } | 674 } |
| OLD | NEW |