| 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, 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 179 |
| 170 | 180 |
| 171 ChromeURLRequestContextGetter* context = | 181 ChromeURLRequestContextGetter* context = |
| 172 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 182 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| 173 profile_, io_data_, app_id); | 183 profile_, io_data_, app_id); |
| 174 app_request_context_getter_map_[app_id] = context; | 184 app_request_context_getter_map_[app_id] = context; |
| 175 | 185 |
| 176 return context; | 186 return context; |
| 177 } | 187 } |
| 178 | 188 |
| 189 void ProfileImplIOData::Handle::DeleteTransportSecurityStateSince( |
| 190 base::Time time) { |
| 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 192 LazyInitialize(); |
| 193 |
| 194 BrowserThread::PostTask( |
| 195 BrowserThread::IO, FROM_HERE, |
| 196 base::Bind( |
| 197 &DeleteTransportSecurityStateSinceOnIOThread, |
| 198 io_data_, |
| 199 time)); |
| 200 } |
| 201 |
| 179 void ProfileImplIOData::Handle::LazyInitialize() const { | 202 void ProfileImplIOData::Handle::LazyInitialize() const { |
| 180 if (!initialized_) { | 203 if (!initialized_) { |
| 181 io_data_->InitializeOnUIThread(profile_); | 204 io_data_->InitializeOnUIThread(profile_); |
| 182 ChromeNetworkDelegate::InitializeReferrersEnabled( | 205 ChromeNetworkDelegate::InitializeReferrersEnabled( |
| 183 io_data_->enable_referrers(), profile_->GetPrefs()); | 206 io_data_->enable_referrers(), profile_->GetPrefs()); |
| 184 io_data_->clear_local_state_on_exit()->Init( | 207 io_data_->clear_local_state_on_exit()->Init( |
| 185 prefs::kClearSiteDataOnExit, profile_->GetPrefs(), NULL); | 208 prefs::kClearSiteDataOnExit, profile_->GetPrefs(), NULL); |
| 186 io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO); | 209 io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO); |
| 187 #if defined(ENABLE_SAFE_BROWSING) | 210 #if defined(ENABLE_SAFE_BROWSING) |
| 188 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, | 211 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 218 bool record_mode = chrome::kRecordModeEnabled && | 241 bool record_mode = chrome::kRecordModeEnabled && |
| 219 command_line.HasSwitch(switches::kRecordMode); | 242 command_line.HasSwitch(switches::kRecordMode); |
| 220 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 243 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
| 221 | 244 |
| 222 // Initialize context members. | 245 // Initialize context members. |
| 223 | 246 |
| 224 ApplyProfileParamsToContext(main_context); | 247 ApplyProfileParamsToContext(main_context); |
| 225 ApplyProfileParamsToContext(media_request_context_); | 248 ApplyProfileParamsToContext(media_request_context_); |
| 226 ApplyProfileParamsToContext(extensions_context); | 249 ApplyProfileParamsToContext(extensions_context); |
| 227 | 250 |
| 251 main_context->set_transport_security_state(transport_security_state()); |
| 252 media_request_context_->set_transport_security_state( |
| 253 transport_security_state()); |
| 254 extensions_context->set_transport_security_state(transport_security_state()); |
| 255 |
| 228 main_context->set_net_log(io_thread->net_log()); | 256 main_context->set_net_log(io_thread->net_log()); |
| 229 media_request_context_->set_net_log(io_thread->net_log()); | 257 media_request_context_->set_net_log(io_thread->net_log()); |
| 230 extensions_context->set_net_log(io_thread->net_log()); | 258 extensions_context->set_net_log(io_thread->net_log()); |
| 231 | 259 |
| 232 main_context->set_network_delegate(network_delegate()); | 260 main_context->set_network_delegate(network_delegate()); |
| 233 media_request_context_->set_network_delegate(network_delegate()); | 261 media_request_context_->set_network_delegate(network_delegate()); |
| 234 | 262 |
| 235 main_context->set_host_resolver( | 263 main_context->set_host_resolver( |
| 236 io_thread_globals->host_resolver.get()); | 264 io_thread_globals->host_resolver.get()); |
| 237 media_request_context_->set_host_resolver( | 265 media_request_context_->set_host_resolver( |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 scoped_refptr<ChromeURLRequestContext> | 462 scoped_refptr<ChromeURLRequestContext> |
| 435 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 463 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 436 scoped_refptr<ChromeURLRequestContext> main_context, | 464 scoped_refptr<ChromeURLRequestContext> main_context, |
| 437 const std::string& app_id) const { | 465 const std::string& app_id) const { |
| 438 // We create per-app contexts on demand, unlike the others above. | 466 // We create per-app contexts on demand, unlike the others above. |
| 439 scoped_refptr<ChromeURLRequestContext> app_request_context = | 467 scoped_refptr<ChromeURLRequestContext> app_request_context = |
| 440 InitializeAppRequestContext(main_context, app_id); | 468 InitializeAppRequestContext(main_context, app_id); |
| 441 DCHECK(app_request_context); | 469 DCHECK(app_request_context); |
| 442 return app_request_context; | 470 return app_request_context; |
| 443 } | 471 } |
| OLD | NEW |