Chromium Code Reviews| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 #include "net/ftp/ftp_network_layer.h" | 58 #include "net/ftp/ftp_network_layer.h" |
| 59 #include "net/http/http_cache.h" | 59 #include "net/http/http_cache.h" |
| 60 #include "net/http/http_network_session.h" | 60 #include "net/http/http_network_session.h" |
| 61 #include "net/http/http_server_properties_manager.h" | 61 #include "net/http/http_server_properties_manager.h" |
| 62 #include "net/sdch/sdch_owner.h" | 62 #include "net/sdch/sdch_owner.h" |
| 63 #include "net/ssl/channel_id_service.h" | 63 #include "net/ssl/channel_id_service.h" |
| 64 #include "net/url_request/url_request_intercepting_job_factory.h" | 64 #include "net/url_request/url_request_intercepting_job_factory.h" |
| 65 #include "net/url_request/url_request_job_factory_impl.h" | 65 #include "net/url_request/url_request_job_factory_impl.h" |
| 66 #include "storage/browser/quota/special_storage_policy.h" | 66 #include "storage/browser/quota/special_storage_policy.h" |
| 67 | 67 |
| 68 #if defined(OS_ANDROID) | |
| 69 #include "chrome/browser/android/data_usage/data_use_tab_model.h" | |
| 70 #include "chrome/browser/android/data_usage/data_use_ui_tab_model.h" | |
| 71 #include "chrome/browser/android/data_usage/data_use_ui_tab_model_factory.h" | |
| 72 #include "chrome/browser/android/data_usage/external_data_use_observer.h" | |
| 73 #endif // defined(OS_ANDROID) | |
| 74 | |
| 68 namespace { | 75 namespace { |
| 69 | 76 |
| 70 net::BackendType ChooseCacheBackendType() { | 77 net::BackendType ChooseCacheBackendType() { |
| 71 #if defined(OS_ANDROID) | 78 #if defined(OS_ANDROID) |
| 72 return net::CACHE_BACKEND_SIMPLE; | 79 return net::CACHE_BACKEND_SIMPLE; |
| 73 #else | 80 #else |
| 74 const base::CommandLine& command_line = | 81 const base::CommandLine& command_line = |
| 75 *base::CommandLine::ForCurrentProcess(); | 82 *base::CommandLine::ForCurrentProcess(); |
| 76 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { | 83 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { |
| 77 const std::string opt_value = | 84 const std::string opt_value = |
| 78 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); | 85 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); |
| 79 if (base::LowerCaseEqualsASCII(opt_value, "off")) | 86 if (base::LowerCaseEqualsASCII(opt_value, "off")) |
| 80 return net::CACHE_BACKEND_BLOCKFILE; | 87 return net::CACHE_BACKEND_BLOCKFILE; |
| 81 if (opt_value.empty() || base::LowerCaseEqualsASCII(opt_value, "on")) | 88 if (opt_value.empty() || base::LowerCaseEqualsASCII(opt_value, "on")) |
| 82 return net::CACHE_BACKEND_SIMPLE; | 89 return net::CACHE_BACKEND_SIMPLE; |
| 83 } | 90 } |
| 84 const std::string experiment_name = | 91 const std::string experiment_name = |
| 85 base::FieldTrialList::FindFullName("SimpleCacheTrial"); | 92 base::FieldTrialList::FindFullName("SimpleCacheTrial"); |
| 86 if (experiment_name == "ExperimentYes" || | 93 if (experiment_name == "ExperimentYes" || |
| 87 experiment_name == "ExperimentYes2") { | 94 experiment_name == "ExperimentYes2") { |
| 88 return net::CACHE_BACKEND_SIMPLE; | 95 return net::CACHE_BACKEND_SIMPLE; |
| 89 } | 96 } |
| 90 return net::CACHE_BACKEND_BLOCKFILE; | 97 return net::CACHE_BACKEND_BLOCKFILE; |
| 91 #endif | 98 #endif |
| 92 } | 99 } |
| 93 | 100 |
| 101 #if defined(OS_ANDROID) | |
| 102 // Returns the weak pointer to DataUseTabModel, and adds |data_use_ui_tab_model| | |
| 103 // as an observer to DataUseTabModel. Must be called only on IO thread. | |
| 104 base::WeakPtr<chrome::android::DataUseTabModel> SetDataUseTabModelOnIOThread( | |
| 105 IOThread* io_thread, | |
| 106 base::WeakPtr<chrome::android::DataUseUITabModel> data_use_ui_tab_model) { | |
| 107 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
| 108 DCHECK(io_thread); | |
| 109 DCHECK(io_thread->globals()); | |
| 110 | |
| 111 base::WeakPtr<chrome::android::DataUseTabModel> data_use_tab_model = | |
| 112 io_thread->globals() | |
| 113 ->external_data_use_observer->GetDataUseTabModel() | |
| 114 ->GetWeakPtr(); | |
| 115 if (data_use_tab_model) | |
| 116 data_use_tab_model->AddObserver(data_use_ui_tab_model); | |
| 117 return data_use_tab_model; | |
| 118 } | |
| 119 | |
| 120 #endif // defined(OS_ANDROID) | |
| 121 | |
| 94 } // namespace | 122 } // namespace |
| 95 | 123 |
| 96 using content::BrowserThread; | 124 using content::BrowserThread; |
| 97 | 125 |
| 98 ProfileImplIOData::Handle::Handle(Profile* profile) | 126 ProfileImplIOData::Handle::Handle(Profile* profile) |
| 99 : io_data_(new ProfileImplIOData), | 127 : io_data_(new ProfileImplIOData), |
| 100 profile_(profile), | 128 profile_(profile), |
| 101 initialized_(false) { | 129 initialized_(false) { |
| 102 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 130 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 103 DCHECK(profile); | 131 DCHECK(profile); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 pool->GetSequenceToken(), | 220 pool->GetSequenceToken(), |
| 193 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 221 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 194 scoped_ptr<data_reduction_proxy::DataStore> store( | 222 scoped_ptr<data_reduction_proxy::DataStore> store( |
| 195 new data_reduction_proxy::DataStoreImpl(profile_path)); | 223 new data_reduction_proxy::DataStoreImpl(profile_path)); |
| 196 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_) | 224 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_) |
| 197 ->InitDataReductionProxySettings( | 225 ->InitDataReductionProxySettings( |
| 198 io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(), | 226 io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(), |
| 199 profile_->GetRequestContext(), store.Pass(), | 227 profile_->GetRequestContext(), store.Pass(), |
| 200 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 228 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 201 db_task_runner); | 229 db_task_runner); |
| 230 | |
| 231 #if defined(OS_ANDROID) | |
| 232 // Pass the DataUseTabModel weak pointer to DataUseUITabModel, and register | |
| 233 // DataUseUITabModel as a DataUseTabModel::TabDataUseObserver. | |
| 234 chrome::android::DataUseUITabModel* data_use_ui_tab_model = | |
| 235 chrome::android::DataUseUITabModelFactory::GetForBrowserContext(profile_); | |
| 236 | |
| 237 if (data_use_ui_tab_model && !io_data_->IsOffTheRecord()) { | |
|
mmenke
2015/12/01 16:45:49
The off the record check isn't actually needed - I
tbansal1
2015/12/01 20:00:07
Got it. I previously verified that ProfileImplIODa
| |
| 238 BrowserThread::PostTaskAndReplyWithResult( | |
| 239 BrowserThread::IO, FROM_HERE, | |
| 240 base::Bind(&SetDataUseTabModelOnIOThread, | |
| 241 g_browser_process->io_thread(), | |
| 242 data_use_ui_tab_model->GetWeakPtr()), | |
| 243 base::Bind(&chrome::android::DataUseUITabModel::SetDataUseTabModel, | |
| 244 data_use_ui_tab_model->GetWeakPtr())); | |
|
mmenke
2015/12/01 16:45:49
Seems like we're micromanaging DataUseUITabModel's
tbansal1
2015/12/01 20:00:07
Done.
| |
| 245 } | |
| 246 #endif // defined(OS_ANDROID) | |
| 202 } | 247 } |
| 203 | 248 |
| 204 content::ResourceContext* | 249 content::ResourceContext* |
| 205 ProfileImplIOData::Handle::GetResourceContext() const { | 250 ProfileImplIOData::Handle::GetResourceContext() const { |
| 206 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 251 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 207 LazyInitialize(); | 252 LazyInitialize(); |
| 208 return GetResourceContextNoInit(); | 253 return GetResourceContextNoInit(); |
| 209 } | 254 } |
| 210 | 255 |
| 211 content::ResourceContext* | 256 content::ResourceContext* |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 const base::Closure& completion) { | 828 const base::Closure& completion) { |
| 784 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 829 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 785 DCHECK(initialized()); | 830 DCHECK(initialized()); |
| 786 | 831 |
| 787 DCHECK(transport_security_state()); | 832 DCHECK(transport_security_state()); |
| 788 // Completes synchronously. | 833 // Completes synchronously. |
| 789 transport_security_state()->DeleteAllDynamicDataSince(time); | 834 transport_security_state()->DeleteAllDynamicDataSince(time); |
| 790 DCHECK(http_server_properties_manager_); | 835 DCHECK(http_server_properties_manager_); |
| 791 http_server_properties_manager_->Clear(completion); | 836 http_server_properties_manager_->Clear(completion); |
| 792 } | 837 } |
| OLD | NEW |