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

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

Issue 901303002: Make SDCH dictionaries persistent across browser restart. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Beef up SdchDictionaryFetcher tests Created 5 years, 10 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
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 <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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const std::string experiment_name = 87 const std::string experiment_name =
84 base::FieldTrialList::FindFullName("SimpleCacheTrial"); 88 base::FieldTrialList::FindFullName("SimpleCacheTrial");
85 if (experiment_name == "ExperimentYes" || 89 if (experiment_name == "ExperimentYes" ||
86 experiment_name == "ExperimentYes2") { 90 experiment_name == "ExperimentYes2") {
87 return net::CACHE_BACKEND_SIMPLE; 91 return net::CACHE_BACKEND_SIMPLE;
88 } 92 }
89 return net::CACHE_BACKEND_BLOCKFILE; 93 return net::CACHE_BACKEND_BLOCKFILE;
90 #endif 94 #endif
91 } 95 }
92 96
97 bool ShouldUseSdchPersistence() {
98 const std::string group =
99 base::FieldTrialList::FindFullName("SdchPersistence");
100 const base::CommandLine* command_line =
101 base::CommandLine::ForCurrentProcess();
102 if (command_line->HasSwitch(switches::kEnableSdchPersistence)) {
103 return true;
104 }
105 if (command_line->HasSwitch(switches::kDisableSdchPersistence)) {
106 return false;
107 }
108 return group == "Enabled";
109 }
110
93 } // namespace 111 } // namespace
94 112
95 using content::BrowserThread; 113 using content::BrowserThread;
96 114
97 ProfileImplIOData::Handle::Handle(Profile* profile) 115 ProfileImplIOData::Handle::Handle(Profile* profile)
98 : io_data_(new ProfileImplIOData), 116 : io_data_(new ProfileImplIOData),
99 profile_(profile), 117 profile_(profile),
100 initialized_(false) { 118 initialized_(false) {
101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
102 DCHECK(profile); 120 DCHECK(profile);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 void ProfileImplIOData::InitializeInternal( 435 void ProfileImplIOData::InitializeInternal(
418 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate, 436 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate,
419 ProfileParams* profile_params, 437 ProfileParams* profile_params,
420 content::ProtocolHandlerMap* protocol_handlers, 438 content::ProtocolHandlerMap* protocol_handlers,
421 content::URLRequestInterceptorScopedVector request_interceptors) const { 439 content::URLRequestInterceptorScopedVector request_interceptors) const {
422 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. 440 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed.
423 tracked_objects::ScopedTracker tracking_profile( 441 tracked_objects::ScopedTracker tracking_profile(
424 FROM_HERE_WITH_EXPLICIT_FUNCTION( 442 FROM_HERE_WITH_EXPLICIT_FUNCTION(
425 "436671 ProfileImplIOData::InitializeInternal")); 443 "436671 ProfileImplIOData::InitializeInternal"));
426 444
445 // Set up a persistent store for use by the network stack on the IO thread.
446 base::FilePath network_json_store_filepath(
447 profile_path_.Append(chrome::kNetworkPersistentStateFilename));
448 network_json_store_ = new JsonPrefStore(
449 network_json_store_filepath,
450 JsonPrefStore::GetTaskRunnerForFile(network_json_store_filepath,
451 BrowserThread::GetBlockingPool()),
452 scoped_ptr<PrefFilter>());
453 network_json_store_->ReadPrefsAsync(nullptr);
Randy Smith (Not in Mondays) 2015/02/23 21:23:49 Given that there's concern around the costs of thi
Elly Fong-Jones 2015/03/03 21:37:44 Talked about this offline and decided not to do it
454
427 net::URLRequestContext* main_context = main_request_context(); 455 net::URLRequestContext* main_context = main_request_context();
428 456
429 IOThread* const io_thread = profile_params->io_thread; 457 IOThread* const io_thread = profile_params->io_thread;
430 IOThread::Globals* const io_thread_globals = io_thread->globals(); 458 IOThread::Globals* const io_thread_globals = io_thread->globals();
431 459
432 chrome_network_delegate->set_predictor(predictor_.get()); 460 chrome_network_delegate->set_predictor(predictor_.get());
433 461
434 if (domain_reliability_monitor_) { 462 if (domain_reliability_monitor_) {
435 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. 463 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed.
436 tracked_objects::ScopedTracker tracking_profile1( 464 tracked_objects::ScopedTracker tracking_profile1(
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 "436671 ProfileImplIOData::InitializeInternal9")); 633 "436671 ProfileImplIOData::InitializeInternal9"));
606 634
607 #if defined(ENABLE_EXTENSIONS) 635 #if defined(ENABLE_EXTENSIONS)
608 InitializeExtensionsRequestContext(profile_params); 636 InitializeExtensionsRequestContext(profile_params);
609 #endif 637 #endif
610 638
611 // Setup SDCH for this profile. 639 // Setup SDCH for this profile.
612 sdch_manager_.reset(new net::SdchManager); 640 sdch_manager_.reset(new net::SdchManager);
613 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context)); 641 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context));
614 main_context->set_sdch_manager(sdch_manager_.get()); 642 main_context->set_sdch_manager(sdch_manager_.get());
643 if (ShouldUseSdchPersistence()) {
644 sdch_policy_->EnablePersistentStorage(network_json_store_.get());
645 }
615 646
616 // Create a media request context based on the main context, but using a 647 // Create a media request context based on the main context, but using a
617 // media cache. It shares the same job factory as the main context. 648 // media cache. It shares the same job factory as the main context.
618 StoragePartitionDescriptor details(profile_path_, false); 649 StoragePartitionDescriptor details(profile_path_, false);
619 media_request_context_.reset(InitializeMediaRequestContext(main_context, 650 media_request_context_.reset(InitializeMediaRequestContext(main_context,
620 details)); 651 details));
621 652
622 lazy_params_.reset(); 653 lazy_params_.reset();
623 } 654 }
624 655
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 const base::Closure& completion) { 878 const base::Closure& completion) {
848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
849 DCHECK(initialized()); 880 DCHECK(initialized());
850 881
851 DCHECK(transport_security_state()); 882 DCHECK(transport_security_state());
852 // Completes synchronously. 883 // Completes synchronously.
853 transport_security_state()->DeleteAllDynamicDataSince(time); 884 transport_security_state()->DeleteAllDynamicDataSince(time);
854 DCHECK(http_server_properties_manager_); 885 DCHECK(http_server_properties_manager_);
855 http_server_properties_manager_->Clear(completion); 886 http_server_properties_manager_->Clear(completion);
856 } 887 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698