Chromium Code Reviews| 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/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 11 matching lines...) Expand all Loading... | |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "content/browser/browser_thread.h" | 25 #include "content/browser/browser_thread.h" |
| 26 #include "content/browser/resource_context.h" | 26 #include "content/browser/resource_context.h" |
| 27 #include "net/base/origin_bound_cert_service.h" | 27 #include "net/base/origin_bound_cert_service.h" |
| 28 #include "net/ftp/ftp_network_layer.h" | 28 #include "net/ftp/ftp_network_layer.h" |
| 29 #include "net/http/http_cache.h" | 29 #include "net/http/http_cache.h" |
| 30 #include "net/url_request/url_request_job_factory.h" | 30 #include "net/url_request/url_request_job_factory.h" |
| 31 | 31 |
| 32 namespace { | |
| 33 | |
| 34 void DeleteTransportSecurityStateSinceOnIOThread( | |
| 35 ProfileImplIOData* io_data, const base::Time& time) { | |
| 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 37 io_data->transport_security_state()->DeleteSince(time); | |
| 38 } | |
| 39 | |
| 40 } // namespace | |
| 41 | |
| 32 ProfileImplIOData::Handle::Handle(Profile* profile) | 42 ProfileImplIOData::Handle::Handle(Profile* profile) |
| 33 : io_data_(new ProfileImplIOData), | 43 : io_data_(new ProfileImplIOData), |
| 34 profile_(profile), | 44 profile_(profile), |
| 35 initialized_(false) { | 45 initialized_(false) { |
| 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 37 DCHECK(profile); | 47 DCHECK(profile); |
| 38 } | 48 } |
| 39 | 49 |
| 40 ProfileImplIOData::Handle::~Handle() { | 50 ProfileImplIOData::Handle::~Handle() { |
| 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 | 174 |
| 165 | 175 |
| 166 ChromeURLRequestContextGetter* context = | 176 ChromeURLRequestContextGetter* context = |
| 167 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 177 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| 168 profile_, io_data_, app_id); | 178 profile_, io_data_, app_id); |
| 169 app_request_context_getter_map_[app_id] = context; | 179 app_request_context_getter_map_[app_id] = context; |
| 170 | 180 |
| 171 return context; | 181 return context; |
| 172 } | 182 } |
| 173 | 183 |
| 184 void ProfileImplIOData::Handle::DeleteTransportSecurityStateSince( | |
| 185 const base::Time& time) { | |
| 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 187 LazyInitialize(); | |
| 188 | |
| 189 BrowserThread::PostTask( | |
| 190 BrowserThread::IO, FROM_HERE, | |
| 191 NewRunnableFunction( | |
|
willchan no longer on Chromium
2011/09/20 01:29:51
This is going to be deprecated soon (stay tuned fo
| |
| 192 &DeleteTransportSecurityStateSinceOnIOThread, | |
| 193 io_data_, | |
| 194 time)); | |
| 195 } | |
| 196 | |
| 174 void ProfileImplIOData::Handle::LazyInitialize() const { | 197 void ProfileImplIOData::Handle::LazyInitialize() const { |
| 175 if (!initialized_) { | 198 if (!initialized_) { |
| 176 io_data_->InitializeOnUIThread(profile_); | 199 io_data_->InitializeOnUIThread(profile_); |
| 177 ChromeNetworkDelegate::InitializeReferrersEnabled( | 200 ChromeNetworkDelegate::InitializeReferrersEnabled( |
| 178 io_data_->enable_referrers(), profile_->GetPrefs()); | 201 io_data_->enable_referrers(), profile_->GetPrefs()); |
| 179 io_data_->clear_local_state_on_exit()->Init( | 202 io_data_->clear_local_state_on_exit()->Init( |
| 180 prefs::kClearSiteDataOnExit, profile_->GetPrefs(), NULL); | 203 prefs::kClearSiteDataOnExit, profile_->GetPrefs(), NULL); |
| 181 io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO); | 204 io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO); |
| 182 #if defined(ENABLE_SAFE_BROWSING) | 205 #if defined(ENABLE_SAFE_BROWSING) |
| 183 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, | 206 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 213 bool record_mode = chrome::kRecordModeEnabled && | 236 bool record_mode = chrome::kRecordModeEnabled && |
| 214 command_line.HasSwitch(switches::kRecordMode); | 237 command_line.HasSwitch(switches::kRecordMode); |
| 215 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 238 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
| 216 | 239 |
| 217 // Initialize context members. | 240 // Initialize context members. |
| 218 | 241 |
| 219 ApplyProfileParamsToContext(main_context); | 242 ApplyProfileParamsToContext(main_context); |
| 220 ApplyProfileParamsToContext(media_request_context_); | 243 ApplyProfileParamsToContext(media_request_context_); |
| 221 ApplyProfileParamsToContext(extensions_context); | 244 ApplyProfileParamsToContext(extensions_context); |
| 222 | 245 |
| 246 main_context->set_transport_security_state(transport_security_state()); | |
| 247 media_request_context_->set_transport_security_state( | |
| 248 transport_security_state()); | |
| 249 extensions_context->set_transport_security_state(transport_security_state()); | |
| 250 | |
| 223 main_context->set_net_log(io_thread->net_log()); | 251 main_context->set_net_log(io_thread->net_log()); |
| 224 media_request_context_->set_net_log(io_thread->net_log()); | 252 media_request_context_->set_net_log(io_thread->net_log()); |
| 225 extensions_context->set_net_log(io_thread->net_log()); | 253 extensions_context->set_net_log(io_thread->net_log()); |
| 226 | 254 |
| 227 main_context->set_network_delegate(network_delegate()); | 255 main_context->set_network_delegate(network_delegate()); |
| 228 media_request_context_->set_network_delegate(network_delegate()); | 256 media_request_context_->set_network_delegate(network_delegate()); |
| 229 | 257 |
| 230 main_context->set_host_resolver( | 258 main_context->set_host_resolver( |
| 231 io_thread_globals->host_resolver.get()); | 259 io_thread_globals->host_resolver.get()); |
| 232 media_request_context_->set_host_resolver( | 260 media_request_context_->set_host_resolver( |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 scoped_refptr<ChromeURLRequestContext> | 457 scoped_refptr<ChromeURLRequestContext> |
| 430 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 458 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 431 scoped_refptr<ChromeURLRequestContext> main_context, | 459 scoped_refptr<ChromeURLRequestContext> main_context, |
| 432 const std::string& app_id) const { | 460 const std::string& app_id) const { |
| 433 // We create per-app contexts on demand, unlike the others above. | 461 // We create per-app contexts on demand, unlike the others above. |
| 434 scoped_refptr<ChromeURLRequestContext> app_request_context = | 462 scoped_refptr<ChromeURLRequestContext> app_request_context = |
| 435 InitializeAppRequestContext(main_context, app_id); | 463 InitializeAppRequestContext(main_context, app_id); |
| 436 DCHECK(app_request_context); | 464 DCHECK(app_request_context); |
| 437 return app_request_context; | 465 return app_request_context; |
| 438 } | 466 } |
| OLD | NEW |