| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 restore_old_session_cookies(false) {} | 244 restore_old_session_cookies(false) {} |
| 245 | 245 |
| 246 ProfileImplIOData::LazyParams::~LazyParams() {} | 246 ProfileImplIOData::LazyParams::~LazyParams() {} |
| 247 | 247 |
| 248 ProfileImplIOData::ProfileImplIOData() | 248 ProfileImplIOData::ProfileImplIOData() |
| 249 : ProfileIOData(false), | 249 : ProfileIOData(false), |
| 250 clear_local_state_on_exit_(false) {} | 250 clear_local_state_on_exit_(false) {} |
| 251 ProfileImplIOData::~ProfileImplIOData() { | 251 ProfileImplIOData::~ProfileImplIOData() { |
| 252 DestroyResourceContext(); | 252 DestroyResourceContext(); |
| 253 | 253 |
| 254 if (media_request_context_) | 254 if (media_request_context_.get()) |
| 255 media_request_context_->AssertNoURLRequests(); | 255 media_request_context_->AssertNoURLRequests(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void ProfileImplIOData::LazyInitializeInternal( | 258 void ProfileImplIOData::LazyInitializeInternal( |
| 259 ProfileParams* profile_params) const { | 259 ProfileParams* profile_params) const { |
| 260 // Keep track of clear_local_state_on_exit for isolated apps. | 260 // Keep track of clear_local_state_on_exit for isolated apps. |
| 261 clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit; | 261 clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit; |
| 262 | 262 |
| 263 ChromeURLRequestContext* main_context = main_request_context(); | 263 ChromeURLRequestContext* main_context = main_request_context(); |
| 264 ChromeURLRequestContext* extensions_context = extensions_request_context(); | 264 ChromeURLRequestContext* extensions_context = extensions_request_context(); |
| 265 media_request_context_ = new ChromeURLRequestContext; | 265 media_request_context_.reset(new ChromeURLRequestContext); |
| 266 | 266 |
| 267 IOThread* const io_thread = profile_params->io_thread; | 267 IOThread* const io_thread = profile_params->io_thread; |
| 268 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 268 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
| 269 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 269 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 270 bool record_mode = chrome::kRecordModeEnabled && | 270 bool record_mode = chrome::kRecordModeEnabled && |
| 271 command_line.HasSwitch(switches::kRecordMode); | 271 command_line.HasSwitch(switches::kRecordMode); |
| 272 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 272 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
| 273 | 273 |
| 274 // Initialize context members. | 274 // Initialize context members. |
| 275 | 275 |
| 276 ApplyProfileParamsToContext(main_context); | 276 ApplyProfileParamsToContext(main_context); |
| 277 ApplyProfileParamsToContext(media_request_context_); | 277 ApplyProfileParamsToContext(media_request_context_.get()); |
| 278 ApplyProfileParamsToContext(extensions_context); | 278 ApplyProfileParamsToContext(extensions_context); |
| 279 | 279 |
| 280 if (http_server_properties_manager()) | 280 if (http_server_properties_manager()) |
| 281 http_server_properties_manager()->InitializeOnIOThread(); | 281 http_server_properties_manager()->InitializeOnIOThread(); |
| 282 | 282 |
| 283 main_context->set_transport_security_state(transport_security_state()); | 283 main_context->set_transport_security_state(transport_security_state()); |
| 284 media_request_context_->set_transport_security_state( | 284 media_request_context_->set_transport_security_state( |
| 285 transport_security_state()); | 285 transport_security_state()); |
| 286 extensions_context->set_transport_security_state(transport_security_state()); | 286 extensions_context->set_transport_security_state(transport_security_state()); |
| 287 | 287 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 main_context->set_job_factory(job_factory()); | 439 main_context->set_job_factory(job_factory()); |
| 440 media_request_context_->set_job_factory(job_factory()); | 440 media_request_context_->set_job_factory(job_factory()); |
| 441 extensions_context->set_job_factory(job_factory()); | 441 extensions_context->set_job_factory(job_factory()); |
| 442 | 442 |
| 443 job_factory()->AddInterceptor( | 443 job_factory()->AddInterceptor( |
| 444 new chrome_browser_net::ConnectInterceptor(predictor_.get())); | 444 new chrome_browser_net::ConnectInterceptor(predictor_.get())); |
| 445 | 445 |
| 446 lazy_params_.reset(); | 446 lazy_params_.reset(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 scoped_refptr<ChromeURLRequestContext> | 449 ChromeURLRequestContext* |
| 450 ProfileImplIOData::InitializeAppRequestContext( | 450 ProfileImplIOData::InitializeAppRequestContext( |
| 451 scoped_refptr<ChromeURLRequestContext> main_context, | 451 ChromeURLRequestContext* main_context, |
| 452 const std::string& app_id) const { | 452 const std::string& app_id) const { |
| 453 AppRequestContext* context = new AppRequestContext; | 453 AppRequestContext* context = new AppRequestContext; |
| 454 | 454 |
| 455 // Copy most state from the main context. | 455 // Copy most state from the main context. |
| 456 context->CopyFrom(main_context); | 456 context->CopyFrom(main_context); |
| 457 | 457 |
| 458 FilePath app_path = app_path_.AppendASCII(app_id); | 458 FilePath app_path = app_path_.AppendASCII(app_id); |
| 459 FilePath cookie_path = app_path.Append(chrome::kCookieFilename); | 459 FilePath cookie_path = app_path.Append(chrome::kCookieFilename); |
| 460 FilePath cache_path = app_path.Append(chrome::kCacheDirname); | 460 FilePath cache_path = app_path.Append(chrome::kCacheDirname); |
| 461 // TODO(creis): Determine correct cache size. | 461 // TODO(creis): Determine correct cache size. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // first. | 501 // first. |
| 502 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); | 502 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); |
| 503 } | 503 } |
| 504 | 504 |
| 505 context->SetCookieStore(cookie_store); | 505 context->SetCookieStore(cookie_store); |
| 506 context->SetHttpTransactionFactory(app_http_cache); | 506 context->SetHttpTransactionFactory(app_http_cache); |
| 507 | 507 |
| 508 return context; | 508 return context; |
| 509 } | 509 } |
| 510 | 510 |
| 511 scoped_refptr<ChromeURLRequestContext> | 511 ChromeURLRequestContext* |
| 512 ProfileImplIOData::AcquireMediaRequestContext() const { | 512 ProfileImplIOData::AcquireMediaRequestContext() const { |
| 513 DCHECK(media_request_context_); | 513 DCHECK(media_request_context_.get()); |
| 514 return media_request_context_; | 514 return media_request_context_.get(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 scoped_refptr<ChromeURLRequestContext> | 517 ChromeURLRequestContext* |
| 518 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 518 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 519 scoped_refptr<ChromeURLRequestContext> main_context, | 519 ChromeURLRequestContext* main_context, |
| 520 const std::string& app_id) const { | 520 const std::string& app_id) const { |
| 521 // We create per-app contexts on demand, unlike the others above. | 521 // We create per-app contexts on demand, unlike the others above. |
| 522 scoped_refptr<ChromeURLRequestContext> app_request_context = | 522 ChromeURLRequestContext* app_request_context = |
| 523 InitializeAppRequestContext(main_context, app_id); | 523 InitializeAppRequestContext(main_context, app_id); |
| 524 DCHECK(app_request_context); | 524 DCHECK(app_request_context); |
| 525 return app_request_context; | 525 return app_request_context; |
| 526 } | 526 } |
| 527 | 527 |
| 528 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( | 528 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( |
| 529 base::Time time) { | 529 base::Time time) { |
| 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 531 LazyInitialize(); | 531 LazyInitialize(); |
| 532 | 532 |
| 533 DCHECK(transport_security_state()); | 533 DCHECK(transport_security_state()); |
| 534 transport_security_state()->DeleteSince(time); | 534 transport_security_state()->DeleteSince(time); |
| 535 DCHECK(http_server_properties_manager()); | 535 DCHECK(http_server_properties_manager()); |
| 536 http_server_properties_manager()->Clear(); | 536 http_server_properties_manager()->Clear(); |
| 537 } | 537 } |
| OLD | NEW |