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 <set> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/prefs/json_pref_store.h" |
| 15 #include "base/prefs/pref_filter.h" |
12 #include "base/prefs/pref_member.h" | 16 #include "base/prefs/pref_member.h" |
13 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
14 #include "base/profiler/scoped_tracker.h" | 18 #include "base/profiler/scoped_tracker.h" |
15 #include "base/sequenced_task_runner.h" | 19 #include "base/sequenced_task_runner.h" |
16 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
17 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/threading/worker_pool.h" | 23 #include "base/threading/worker_pool.h" |
20 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const std::string experiment_name = | 82 const std::string experiment_name = |
79 base::FieldTrialList::FindFullName("SimpleCacheTrial"); | 83 base::FieldTrialList::FindFullName("SimpleCacheTrial"); |
80 if (experiment_name == "ExperimentYes" || | 84 if (experiment_name == "ExperimentYes" || |
81 experiment_name == "ExperimentYes2") { | 85 experiment_name == "ExperimentYes2") { |
82 return net::CACHE_BACKEND_SIMPLE; | 86 return net::CACHE_BACKEND_SIMPLE; |
83 } | 87 } |
84 return net::CACHE_BACKEND_BLOCKFILE; | 88 return net::CACHE_BACKEND_BLOCKFILE; |
85 #endif | 89 #endif |
86 } | 90 } |
87 | 91 |
| 92 bool ShouldUseSdchPersistence() { |
| 93 const std::string group = |
| 94 base::FieldTrialList::FindFullName("SdchPersistence"); |
| 95 const base::CommandLine* command_line = |
| 96 base::CommandLine::ForCurrentProcess(); |
| 97 if (command_line->HasSwitch(switches::kEnableSdchPersistence)) { |
| 98 return true; |
| 99 } |
| 100 if (command_line->HasSwitch(switches::kDisableSdchPersistence)) { |
| 101 return false; |
| 102 } |
| 103 return group == "Enabled"; |
| 104 } |
| 105 |
88 } // namespace | 106 } // namespace |
89 | 107 |
90 using content::BrowserThread; | 108 using content::BrowserThread; |
91 | 109 |
92 ProfileImplIOData::Handle::Handle(Profile* profile) | 110 ProfileImplIOData::Handle::Handle(Profile* profile) |
93 : io_data_(new ProfileImplIOData), | 111 : io_data_(new ProfileImplIOData), |
94 profile_(profile), | 112 profile_(profile), |
95 initialized_(false) { | 113 initialized_(false) { |
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
97 DCHECK(profile); | 115 DCHECK(profile); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 void ProfileImplIOData::InitializeInternal( | 434 void ProfileImplIOData::InitializeInternal( |
417 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate, | 435 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate, |
418 ProfileParams* profile_params, | 436 ProfileParams* profile_params, |
419 content::ProtocolHandlerMap* protocol_handlers, | 437 content::ProtocolHandlerMap* protocol_handlers, |
420 content::URLRequestInterceptorScopedVector request_interceptors) const { | 438 content::URLRequestInterceptorScopedVector request_interceptors) const { |
421 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | 439 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. |
422 tracked_objects::ScopedTracker tracking_profile( | 440 tracked_objects::ScopedTracker tracking_profile( |
423 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 441 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
424 "436671 ProfileImplIOData::InitializeInternal")); | 442 "436671 ProfileImplIOData::InitializeInternal")); |
425 | 443 |
| 444 // Set up a persistent store for use by the network stack on the IO thread. |
| 445 base::FilePath network_json_store_filepath( |
| 446 profile_path_.Append(chrome::kNetworkPersistentStateFilename)); |
| 447 network_json_store_ = new JsonPrefStore( |
| 448 network_json_store_filepath, |
| 449 JsonPrefStore::GetTaskRunnerForFile(network_json_store_filepath, |
| 450 BrowserThread::GetBlockingPool()), |
| 451 scoped_ptr<PrefFilter>()); |
| 452 network_json_store_->ReadPrefsAsync(nullptr); |
| 453 |
426 net::URLRequestContext* main_context = main_request_context(); | 454 net::URLRequestContext* main_context = main_request_context(); |
427 | 455 |
428 IOThread* const io_thread = profile_params->io_thread; | 456 IOThread* const io_thread = profile_params->io_thread; |
429 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 457 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
430 | 458 |
431 chrome_network_delegate->set_predictor(predictor_.get()); | 459 chrome_network_delegate->set_predictor(predictor_.get()); |
432 | 460 |
433 if (domain_reliability_monitor_) { | 461 if (domain_reliability_monitor_) { |
434 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. | 462 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. |
435 tracked_objects::ScopedTracker tracking_profile1( | 463 tracked_objects::ScopedTracker tracking_profile1( |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 "436671 ProfileImplIOData::InitializeInternal9")); | 632 "436671 ProfileImplIOData::InitializeInternal9")); |
605 | 633 |
606 #if defined(ENABLE_EXTENSIONS) | 634 #if defined(ENABLE_EXTENSIONS) |
607 InitializeExtensionsRequestContext(profile_params); | 635 InitializeExtensionsRequestContext(profile_params); |
608 #endif | 636 #endif |
609 | 637 |
610 // Setup SDCH for this profile. | 638 // Setup SDCH for this profile. |
611 sdch_manager_.reset(new net::SdchManager); | 639 sdch_manager_.reset(new net::SdchManager); |
612 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context)); | 640 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context)); |
613 main_context->set_sdch_manager(sdch_manager_.get()); | 641 main_context->set_sdch_manager(sdch_manager_.get()); |
| 642 if (ShouldUseSdchPersistence()) { |
| 643 sdch_policy_->EnablePersistentStorage(network_json_store_.get()); |
| 644 } |
614 | 645 |
615 // Create a media request context based on the main context, but using a | 646 // Create a media request context based on the main context, but using a |
616 // media cache. It shares the same job factory as the main context. | 647 // media cache. It shares the same job factory as the main context. |
617 StoragePartitionDescriptor details(profile_path_, false); | 648 StoragePartitionDescriptor details(profile_path_, false); |
618 media_request_context_.reset(InitializeMediaRequestContext(main_context, | 649 media_request_context_.reset(InitializeMediaRequestContext(main_context, |
619 details)); | 650 details)); |
620 | 651 |
621 lazy_params_.reset(); | 652 lazy_params_.reset(); |
622 } | 653 } |
623 | 654 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 const base::Closure& completion) { | 877 const base::Closure& completion) { |
847 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 878 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
848 DCHECK(initialized()); | 879 DCHECK(initialized()); |
849 | 880 |
850 DCHECK(transport_security_state()); | 881 DCHECK(transport_security_state()); |
851 // Completes synchronously. | 882 // Completes synchronously. |
852 transport_security_state()->DeleteAllDynamicDataSince(time); | 883 transport_security_state()->DeleteAllDynamicDataSince(time); |
853 DCHECK(http_server_properties_manager_); | 884 DCHECK(http_server_properties_manager_); |
854 http_server_properties_manager_->Clear(completion); | 885 http_server_properties_manager_->Clear(completion); |
855 } | 886 } |
OLD | NEW |