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

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

Issue 7384008: Revert 92668 - Remove more unnecessary ChromeURLRequestContext members. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 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) 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_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/stl_util-inl.h" 13 #include "base/stl_util-inl.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/task.h"
16 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/content_settings/host_content_settings_map.h" 16 #include "chrome/browser/content_settings/host_content_settings_map.h"
18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
19 #include "chrome/browser/extensions/extension_info_map.h"
20 #include "chrome/browser/extensions/extension_protocols.h" 18 #include "chrome/browser/extensions/extension_protocols.h"
21 #include "chrome/browser/io_thread.h" 19 #include "chrome/browser/io_thread.h"
22 #include "chrome/browser/media/media_internals.h" 20 #include "chrome/browser/media/media_internals.h"
23 #include "chrome/browser/net/chrome_cookie_notification_details.h" 21 #include "chrome/browser/net/chrome_cookie_notification_details.h"
24 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" 22 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h"
25 #include "chrome/browser/net/chrome_net_log.h" 23 #include "chrome/browser/net/chrome_net_log.h"
26 #include "chrome/browser/net/chrome_network_delegate.h" 24 #include "chrome/browser/net/chrome_network_delegate.h"
27 #include "chrome/browser/net/pref_proxy_config_service.h" 25 #include "chrome/browser/net/pref_proxy_config_service.h"
28 #include "chrome/browser/net/proxy_service_factory.h" 26 #include "chrome/browser/net/proxy_service_factory.h"
29 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 27 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
30 #include "chrome/browser/prefs/pref_service.h" 28 #include "chrome/browser/prefs/pref_service.h"
31 #include "chrome/browser/prerender/prerender_manager.h" 29 #include "chrome/browser/prerender/prerender_manager.h"
32 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" 31 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
34 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
37 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
38 #include "content/browser/appcache/chrome_appcache_service.h"
39 #include "content/browser/browser_thread.h" 36 #include "content/browser/browser_thread.h"
40 #include "content/browser/chrome_blob_storage_context.h"
41 #include "content/browser/host_zoom_map.h" 37 #include "content/browser/host_zoom_map.h"
42 #include "content/browser/renderer_host/resource_dispatcher_host.h" 38 #include "content/browser/renderer_host/resource_dispatcher_host.h"
43 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 39 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
44 #include "content/browser/resource_context.h" 40 #include "content/browser/resource_context.h"
45 #include "content/common/notification_service.h" 41 #include "content/common/notification_service.h"
46 #include "net/http/http_transaction_factory.h" 42 #include "net/http/http_transaction_factory.h"
47 #include "net/http/http_util.h" 43 #include "net/http/http_util.h"
48 #include "net/proxy/proxy_config_service_fixed.h" 44 #include "net/proxy/proxy_config_service_fixed.h"
49 #include "net/proxy/proxy_script_fetcher_impl.h" 45 #include "net/proxy/proxy_script_fetcher_impl.h"
50 #include "net/proxy/proxy_service.h" 46 #include "net/proxy/proxy_service.h"
51 #include "net/url_request/url_request.h" 47 #include "net/url_request/url_request.h"
52 #include "webkit/blob/blob_data.h" 48 #include "webkit/blob/blob_data.h"
53 #include "webkit/blob/blob_url_request_job_factory.h" 49 #include "webkit/blob/blob_url_request_job_factory.h"
54 #include "webkit/fileapi/file_system_context.h"
55 #include "webkit/fileapi/file_system_url_request_job_factory.h" 50 #include "webkit/fileapi/file_system_url_request_job_factory.h"
56 #include "webkit/database/database_tracker.h" 51 #include "webkit/database/database_tracker.h"
57 #include "webkit/quota/quota_manager.h" 52 #include "webkit/quota/quota_manager.h"
58 53
59 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
60 #include "chrome/browser/chromeos/gview_request_interceptor.h" 55 #include "chrome/browser/chromeos/gview_request_interceptor.h"
61 #endif // defined(OS_CHROMEOS) 56 #endif // defined(OS_CHROMEOS)
62 57
63 namespace { 58 namespace {
64 59
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 profile(NULL) {} 296 profile(NULL) {}
302 ProfileIOData::ProfileParams::~ProfileParams() {} 297 ProfileIOData::ProfileParams::~ProfileParams() {}
303 298
304 ProfileIOData::ProfileIOData(bool is_incognito) 299 ProfileIOData::ProfileIOData(bool is_incognito)
305 : initialized_(false), 300 : initialized_(false),
306 ALLOW_THIS_IN_INITIALIZER_LIST(resource_context_(this)) { 301 ALLOW_THIS_IN_INITIALIZER_LIST(resource_context_(this)) {
307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
308 } 303 }
309 304
310 ProfileIOData::~ProfileIOData() { 305 ProfileIOData::~ProfileIOData() {
311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 306 // If we have never initialized ProfileIOData, then Handle may hold the only
307 // reference to it. The important thing is to make sure it hasn't been
308 // initialized yet, because the lazily initialized variables are supposed to
309 // live on the IO thread.
310 if (BrowserThread::CurrentlyOn(BrowserThread::UI))
311 DCHECK(!initialized_);
312 else
313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
312 } 314 }
313 315
314 // static 316 // static
315 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { 317 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) {
316 DCHECK_EQ(scheme, StringToLowerASCII(scheme)); 318 DCHECK_EQ(scheme, StringToLowerASCII(scheme));
317 static const char* const kProtocolList[] = { 319 static const char* const kProtocolList[] = {
318 chrome::kExtensionScheme, 320 chrome::kExtensionScheme,
319 chrome::kChromeUIScheme, 321 chrome::kChromeUIScheme,
320 chrome::kChromeDevToolsScheme, 322 chrome::kChromeDevToolsScheme,
321 #if defined(OS_CHROMEOS) 323 #if defined(OS_CHROMEOS)
(...skipping 11 matching lines...) Expand all
333 335
334 bool ProfileIOData::IsHandledURL(const GURL& url) { 336 bool ProfileIOData::IsHandledURL(const GURL& url) {
335 if (!url.is_valid()) { 337 if (!url.is_valid()) {
336 // We handle error cases. 338 // We handle error cases.
337 return true; 339 return true;
338 } 340 }
339 341
340 return IsHandledProtocol(url.scheme()); 342 return IsHandledProtocol(url.scheme());
341 } 343 }
342 344
343 const content::ResourceContext& ProfileIOData::GetResourceContext() const {
344 return resource_context_;
345 }
346
347 ChromeURLDataManagerBackend*
348 ProfileIOData::GetChromeURLDataManagerBackend() const {
349 LazyInitialize();
350 return chrome_url_data_manager_backend_.get();
351 }
352
353 scoped_refptr<ChromeURLRequestContext> 345 scoped_refptr<ChromeURLRequestContext>
354 ProfileIOData::GetMainRequestContext() const { 346 ProfileIOData::GetMainRequestContext() const {
355 LazyInitialize(); 347 LazyInitialize();
356 scoped_refptr<RequestContext> context = main_request_context_; 348 scoped_refptr<RequestContext> context = main_request_context_;
357 context->set_profile_io_data(const_cast<ProfileIOData*>(this)); 349 context->set_profile_io_data(const_cast<ProfileIOData*>(this));
358 main_request_context_ = NULL; 350 main_request_context_ = NULL;
359 return context; 351 return context;
360 } 352 }
361 353
362 scoped_refptr<ChromeURLRequestContext> 354 scoped_refptr<ChromeURLRequestContext>
(...skipping 27 matching lines...) Expand all
390 scoped_refptr<RequestContext> request_context = 382 scoped_refptr<RequestContext> request_context =
391 AcquireIsolatedAppRequestContext(main_context, app_id); 383 AcquireIsolatedAppRequestContext(main_context, app_id);
392 request_context->set_profile_io_data(const_cast<ProfileIOData*>(this)); 384 request_context->set_profile_io_data(const_cast<ProfileIOData*>(this));
393 app_request_context_map_[app_id] = request_context; 385 app_request_context_map_[app_id] = request_context;
394 context = request_context; 386 context = request_context;
395 } 387 }
396 DCHECK(context); 388 DCHECK(context);
397 return context; 389 return context;
398 } 390 }
399 391
392 const content::ResourceContext& ProfileIOData::GetResourceContext() const {
393 return resource_context_;
394 }
395
400 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const { 396 ExtensionInfoMap* ProfileIOData::GetExtensionInfoMap() const {
401 return extension_info_map_; 397 return extension_info_map_;
402 } 398 }
403 399
404 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { 400 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const {
405 return host_content_settings_map_; 401 return host_content_settings_map_;
406 } 402 }
407 403
408 DesktopNotificationService* ProfileIOData::GetNotificationService() const { 404 DesktopNotificationService* ProfileIOData::GetNotificationService() const {
409 return notification_service_; 405 return notification_service_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 462 }
467 bool set_protocol = job_factory_->SetProtocolHandler( 463 bool set_protocol = job_factory_->SetProtocolHandler(
468 chrome::kExtensionScheme, 464 chrome::kExtensionScheme,
469 CreateExtensionProtocolHandler(profile_params_->is_incognito, 465 CreateExtensionProtocolHandler(profile_params_->is_incognito,
470 profile_params_->extension_info_map)); 466 profile_params_->extension_info_map));
471 DCHECK(set_protocol); 467 DCHECK(set_protocol);
472 set_protocol = job_factory_->SetProtocolHandler( 468 set_protocol = job_factory_->SetProtocolHandler(
473 chrome::kChromeUIScheme, 469 chrome::kChromeUIScheme,
474 ChromeURLDataManagerBackend::CreateProtocolHandler( 470 ChromeURLDataManagerBackend::CreateProtocolHandler(
475 chrome_url_data_manager_backend_.get(), 471 chrome_url_data_manager_backend_.get(),
476 profile_params_->appcache_service, 472 profile_params_->appcache_service));
477 profile_params_->blob_storage_context->controller()));
478 DCHECK(set_protocol); 473 DCHECK(set_protocol);
479 set_protocol = job_factory_->SetProtocolHandler( 474 set_protocol = job_factory_->SetProtocolHandler(
480 chrome::kChromeDevToolsScheme, 475 chrome::kChromeDevToolsScheme,
481 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get())); 476 CreateDevToolsProtocolHandler(chrome_url_data_manager_backend_.get()));
482 DCHECK(set_protocol); 477 DCHECK(set_protocol);
483 set_protocol = job_factory_->SetProtocolHandler( 478 set_protocol = job_factory_->SetProtocolHandler(
484 chrome::kBlobScheme, 479 chrome::kBlobScheme,
485 new ChromeBlobProtocolHandler( 480 new ChromeBlobProtocolHandler(
486 profile_params_->blob_storage_context->controller(), 481 profile_params_->blob_storage_context->controller(),
487 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); 482 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 528
534 void ProfileIOData::ApplyProfileParamsToContext( 529 void ProfileIOData::ApplyProfileParamsToContext(
535 ChromeURLRequestContext* context) const { 530 ChromeURLRequestContext* context) const {
536 context->set_is_incognito(profile_params_->is_incognito); 531 context->set_is_incognito(profile_params_->is_incognito);
537 context->set_accept_language(profile_params_->accept_language); 532 context->set_accept_language(profile_params_->accept_language);
538 context->set_accept_charset(profile_params_->accept_charset); 533 context->set_accept_charset(profile_params_->accept_charset);
539 context->set_referrer_charset(profile_params_->referrer_charset); 534 context->set_referrer_charset(profile_params_->referrer_charset);
540 context->set_transport_security_state( 535 context->set_transport_security_state(
541 profile_params_->transport_security_state); 536 profile_params_->transport_security_state);
542 context->set_ssl_config_service(profile_params_->ssl_config_service); 537 context->set_ssl_config_service(profile_params_->ssl_config_service);
538 context->set_appcache_service(profile_params_->appcache_service);
539 context->set_blob_storage_context(profile_params_->blob_storage_context);
540 context->set_file_system_context(profile_params_->file_system_context);
541 context->set_extension_info_map(profile_params_->extension_info_map);
543 } 542 }
544 543
545 void ProfileIOData::ShutdownOnUIThread() { 544 void ProfileIOData::ShutdownOnUIThread() {
546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
547 enable_referrers_.Destroy(); 546 enable_referrers_.Destroy();
548 clear_local_state_on_exit_.Destroy(); 547 clear_local_state_on_exit_.Destroy();
549 safe_browsing_enabled_.Destroy(); 548 safe_browsing_enabled_.Destroy();
550 bool posted = BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
551 new ReleaseTask<ProfileIOData>(this));
552 DCHECK(posted);
553 } 549 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.h ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698