| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 profile_, io_data_); | 134 profile_, io_data_); |
| 135 } | 135 } |
| 136 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), | 136 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), |
| 137 local_state, | 137 local_state, |
| 138 io_thread, | 138 io_thread, |
| 139 main_request_context_getter_); | 139 main_request_context_getter_); |
| 140 | 140 |
| 141 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 141 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ProfileImplIOData::Handle::InitForTesting() const { |
| 145 using chrome_browser_net::HttpServerPropertiesManager; |
| 146 |
| 147 initialized_ = true; |
| 148 |
| 149 // Set up an HttpServerPropertiesManager for testing removing browsing data. |
| 150 PrefService* pref_service = profile_->GetPrefs(); |
| 151 io_data_->set_http_server_properties_manager( |
| 152 new HttpServerPropertiesManager(pref_service)); |
| 153 |
| 154 BrowserThread::PostTask( |
| 155 BrowserThread::IO, |
| 156 FROM_HERE, |
| 157 base::Bind( |
| 158 &HttpServerPropertiesManager::InitializeOnIOThread, |
| 159 base::Unretained(io_data_->http_server_properties_manager()))); |
| 160 |
| 161 io_data_->InitForTesting(); |
| 162 } |
| 163 |
| 144 base::Callback<ChromeURLDataManagerBackend*(void)> | 164 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 145 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { | 165 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { |
| 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 147 LazyInitialize(); | 167 LazyInitialize(); |
| 148 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, | 168 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, |
| 149 base::Unretained(io_data_)); | 169 base::Unretained(io_data_)); |
| 150 } | 170 } |
| 151 | 171 |
| 152 content::ResourceContext* | 172 content::ResourceContext* |
| 153 ProfileImplIOData::Handle::GetResourceContext() const { | 173 ProfileImplIOData::Handle::GetResourceContext() const { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 GetIsolatedAppRequestContextGetter(app_id); | 271 GetIsolatedAppRequestContextGetter(app_id); |
| 252 ChromeURLRequestContextGetter* context = | 272 ChromeURLRequestContextGetter* context = |
| 253 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( | 273 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia( |
| 254 profile_, app_context, io_data_, app_id); | 274 profile_, app_context, io_data_, app_id); |
| 255 isolated_media_request_context_getter_map_[app_id] = context; | 275 isolated_media_request_context_getter_map_[app_id] = context; |
| 256 | 276 |
| 257 return context; | 277 return context; |
| 258 } | 278 } |
| 259 | 279 |
| 260 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( | 280 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( |
| 261 base::Time time) { | 281 base::Time time, |
| 282 const base::Closure& completion) { |
| 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 263 LazyInitialize(); | 284 LazyInitialize(); |
| 264 | 285 |
| 265 BrowserThread::PostTask( | 286 BrowserThread::PostTask( |
| 266 BrowserThread::IO, FROM_HERE, | 287 BrowserThread::IO, FROM_HERE, |
| 267 base::Bind( | 288 base::Bind( |
| 268 &ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread, | 289 &ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread, |
| 269 base::Unretained(io_data_), | 290 base::Unretained(io_data_), |
| 270 time)); | 291 time, |
| 292 completion)); |
| 271 } | 293 } |
| 272 | 294 |
| 273 void ProfileImplIOData::Handle::LazyInitialize() const { | 295 void ProfileImplIOData::Handle::LazyInitialize() const { |
| 274 if (initialized_) | 296 if (initialized_) |
| 275 return; | 297 return; |
| 276 | 298 |
| 277 // Set initialized_ to true at the beginning in case any of the objects | 299 // Set initialized_ to true at the beginning in case any of the objects |
| 278 // below try to get the ResourceContext pointer. | 300 // below try to get the ResourceContext pointer. |
| 279 initialized_ = true; | 301 initialized_ = true; |
| 280 PrefService* pref_service = profile_->GetPrefs(); | 302 PrefService* pref_service = profile_->GetPrefs(); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 net::FtpAuthCache* ftp_auth_cache) const { | 678 net::FtpAuthCache* ftp_auth_cache) const { |
| 657 SetUpJobFactoryDefaults(job_factory, protocol_handler_interceptor.Pass(), | 679 SetUpJobFactoryDefaults(job_factory, protocol_handler_interceptor.Pass(), |
| 658 network_delegate, ftp_transaction_factory, | 680 network_delegate, ftp_transaction_factory, |
| 659 ftp_auth_cache); | 681 ftp_auth_cache); |
| 660 | 682 |
| 661 job_factory->AddInterceptor( | 683 job_factory->AddInterceptor( |
| 662 new chrome_browser_net::ConnectInterceptor(predictor_.get())); | 684 new chrome_browser_net::ConnectInterceptor(predictor_.get())); |
| 663 } | 685 } |
| 664 | 686 |
| 665 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 687 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 666 base::Time time) { | 688 base::Time time, |
| 689 const base::Closure& completion) { |
| 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 690 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 668 LazyInitialize(); | 691 LazyInitialize(); |
| 669 | 692 |
| 670 DCHECK(transport_security_state()); | 693 DCHECK(transport_security_state()); |
| 671 transport_security_state()->DeleteSince(time); | 694 transport_security_state()->DeleteSince(time); // Completes synchronously. |
| 672 DCHECK(http_server_properties_manager()); | 695 DCHECK(http_server_properties_manager()); |
| 673 http_server_properties_manager()->Clear(); | 696 http_server_properties_manager()->Clear(completion); |
| 674 } | 697 } |
| OLD | NEW |