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