Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(933)

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize to NULL Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 restore_old_session_cookies(false) {} 245 restore_old_session_cookies(false) {}
246 246
247 ProfileImplIOData::LazyParams::~LazyParams() {} 247 ProfileImplIOData::LazyParams::~LazyParams() {}
248 248
249 ProfileImplIOData::ProfileImplIOData() 249 ProfileImplIOData::ProfileImplIOData()
250 : ProfileIOData(false), 250 : ProfileIOData(false),
251 clear_local_state_on_exit_(false) {} 251 clear_local_state_on_exit_(false) {}
252 ProfileImplIOData::~ProfileImplIOData() { 252 ProfileImplIOData::~ProfileImplIOData() {
253 DestroyResourceContext(); 253 DestroyResourceContext();
254 254
255 if (media_request_context_) 255 if (media_request_context_.get())
256 media_request_context_->AssertNoURLRequests(); 256 media_request_context_->AssertNoURLRequests();
257 } 257 }
258 258
259 void ProfileImplIOData::LazyInitializeInternal( 259 void ProfileImplIOData::LazyInitializeInternal(
260 ProfileParams* profile_params) const { 260 ProfileParams* profile_params) const {
261 // Keep track of clear_local_state_on_exit for isolated apps. 261 // Keep track of clear_local_state_on_exit for isolated apps.
262 clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit; 262 clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit;
263 263
264 ChromeURLRequestContext* main_context = main_request_context(); 264 ChromeURLRequestContext* main_context = main_request_context();
265 ChromeURLRequestContext* extensions_context = extensions_request_context(); 265 ChromeURLRequestContext* extensions_context = extensions_request_context();
266 media_request_context_ = new ChromeURLRequestContext; 266 media_request_context_.reset(new ChromeURLRequestContext);
267 267
268 IOThread* const io_thread = profile_params->io_thread; 268 IOThread* const io_thread = profile_params->io_thread;
269 IOThread::Globals* const io_thread_globals = io_thread->globals(); 269 IOThread::Globals* const io_thread_globals = io_thread->globals();
270 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 270 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
271 bool record_mode = chrome::kRecordModeEnabled && 271 bool record_mode = chrome::kRecordModeEnabled &&
272 command_line.HasSwitch(switches::kRecordMode); 272 command_line.HasSwitch(switches::kRecordMode);
273 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); 273 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode);
274 274
275 // Initialize context members. 275 // Initialize context members.
276 276
277 ApplyProfileParamsToContext(main_context); 277 ApplyProfileParamsToContext(main_context);
278 ApplyProfileParamsToContext(media_request_context_); 278 ApplyProfileParamsToContext(media_request_context_.get());
279 ApplyProfileParamsToContext(extensions_context); 279 ApplyProfileParamsToContext(extensions_context);
280 280
281 if (http_server_properties_manager()) 281 if (http_server_properties_manager())
282 http_server_properties_manager()->InitializeOnIOThread(); 282 http_server_properties_manager()->InitializeOnIOThread();
283 283
284 main_context->set_transport_security_state(transport_security_state()); 284 main_context->set_transport_security_state(transport_security_state());
285 media_request_context_->set_transport_security_state( 285 media_request_context_->set_transport_security_state(
286 transport_security_state()); 286 transport_security_state());
287 extensions_context->set_transport_security_state(transport_security_state()); 287 extensions_context->set_transport_security_state(transport_security_state());
288 288
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 main_context->set_job_factory(job_factory()); 442 main_context->set_job_factory(job_factory());
443 media_request_context_->set_job_factory(job_factory()); 443 media_request_context_->set_job_factory(job_factory());
444 extensions_context->set_job_factory(job_factory()); 444 extensions_context->set_job_factory(job_factory());
445 445
446 job_factory()->AddInterceptor( 446 job_factory()->AddInterceptor(
447 new chrome_browser_net::ConnectInterceptor(predictor_.get())); 447 new chrome_browser_net::ConnectInterceptor(predictor_.get()));
448 448
449 lazy_params_.reset(); 449 lazy_params_.reset();
450 } 450 }
451 451
452 scoped_refptr<ChromeURLRequestContext> 452 ChromeURLRequestContext*
453 ProfileImplIOData::InitializeAppRequestContext( 453 ProfileImplIOData::InitializeAppRequestContext(
454 scoped_refptr<ChromeURLRequestContext> main_context, 454 ChromeURLRequestContext* main_context,
455 const std::string& app_id) const { 455 const std::string& app_id) const {
456 AppRequestContext* context = new AppRequestContext; 456 AppRequestContext* context = new AppRequestContext;
457 457
458 // Copy most state from the main context. 458 // Copy most state from the main context.
459 context->CopyFrom(main_context); 459 context->CopyFrom(main_context);
460 460
461 FilePath app_path = app_path_.AppendASCII(app_id); 461 FilePath app_path = app_path_.AppendASCII(app_id);
462 FilePath cookie_path = app_path.Append(chrome::kCookieFilename); 462 FilePath cookie_path = app_path.Append(chrome::kCookieFilename);
463 FilePath cache_path = app_path.Append(chrome::kCacheDirname); 463 FilePath cache_path = app_path.Append(chrome::kCacheDirname);
464 // TODO(creis): Determine correct cache size. 464 // TODO(creis): Determine correct cache size.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // first. 504 // first.
505 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); 505 cookie_store = new net::CookieMonster(cookie_db.get(), NULL);
506 } 506 }
507 507
508 context->SetCookieStore(cookie_store); 508 context->SetCookieStore(cookie_store);
509 context->SetHttpTransactionFactory(app_http_cache); 509 context->SetHttpTransactionFactory(app_http_cache);
510 510
511 return context; 511 return context;
512 } 512 }
513 513
514 scoped_refptr<ChromeURLRequestContext> 514 ChromeURLRequestContext*
515 ProfileImplIOData::AcquireMediaRequestContext() const { 515 ProfileImplIOData::AcquireMediaRequestContext() const {
516 DCHECK(media_request_context_); 516 DCHECK(media_request_context_.get());
517 return media_request_context_; 517 return media_request_context_.get();
518 } 518 }
519 519
520 scoped_refptr<ChromeURLRequestContext> 520 ChromeURLRequestContext*
521 ProfileImplIOData::AcquireIsolatedAppRequestContext( 521 ProfileImplIOData::AcquireIsolatedAppRequestContext(
522 scoped_refptr<ChromeURLRequestContext> main_context, 522 ChromeURLRequestContext* main_context,
523 const std::string& app_id) const { 523 const std::string& app_id) const {
524 // We create per-app contexts on demand, unlike the others above. 524 // We create per-app contexts on demand, unlike the others above.
525 scoped_refptr<ChromeURLRequestContext> app_request_context = 525 ChromeURLRequestContext* app_request_context =
526 InitializeAppRequestContext(main_context, app_id); 526 InitializeAppRequestContext(main_context, app_id);
527 DCHECK(app_request_context); 527 DCHECK(app_request_context);
528 return app_request_context; 528 return app_request_context;
529 } 529 }
530 530
531 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( 531 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread(
532 base::Time time) { 532 base::Time time) {
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
534 LazyInitialize(); 534 LazyInitialize();
535 535
536 DCHECK(transport_security_state()); 536 DCHECK(transport_security_state());
537 transport_security_state()->DeleteSince(time); 537 transport_security_state()->DeleteSince(time);
538 DCHECK(http_server_properties_manager()); 538 DCHECK(http_server_properties_manager());
539 http_server_properties_manager()->Clear(); 539 http_server_properties_manager()->Clear();
540 } 540 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698