| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/cronet/host_cache_persistence_manager.h" | 5 #include "components/cronet/host_cache_persistence_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "components/prefs/pref_service.h" | 11 #include "components/prefs/pref_service.h" |
| 12 | 12 |
| 13 namespace cronet { | 13 namespace cronet { |
| 14 | 14 |
| 15 HostCachePersistenceManager::HostCachePersistenceManager( | 15 HostCachePersistenceManager::HostCachePersistenceManager( |
| 16 net::HostCache* cache, | 16 net::HostCache* cache, |
| 17 PrefService* pref_service, | 17 PrefService* pref_service, |
| 18 std::string pref_name, | 18 std::string pref_name, |
| 19 base::TimeDelta delay) | 19 base::TimeDelta delay) |
| 20 : cache_(cache), | 20 : cache_(cache), |
| 21 pref_service_(pref_service), | 21 pref_service_(pref_service), |
| 22 pref_name_(pref_name), | 22 pref_name_(pref_name), |
| 23 writing_pref_(false), |
| 23 delay_(delay), | 24 delay_(delay), |
| 24 weak_factory_(this) { | 25 weak_factory_(this) { |
| 25 DCHECK(cache_); | 26 DCHECK(cache_); |
| 26 DCHECK(pref_service_); | 27 DCHECK(pref_service_); |
| 27 | 28 |
| 28 // Get the initial value of the pref if it's already initialized. | 29 // Get the initial value of the pref if it's already initialized. |
| 29 if (pref_service_->HasPrefPath(pref_name_)) | 30 if (pref_service_->HasPrefPath(pref_name_)) |
| 30 ReadFromDisk(); | 31 ReadFromDisk(); |
| 31 | 32 |
| 32 registrar_.Init(pref_service_); | 33 registrar_.Init(pref_service_); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 70 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 70 | 71 |
| 71 base::ListValue value; | 72 base::ListValue value; |
| 72 cache_->GetAsListValue(&value, false); | 73 cache_->GetAsListValue(&value, false); |
| 73 writing_pref_ = true; | 74 writing_pref_ = true; |
| 74 pref_service_->Set(pref_name_, value); | 75 pref_service_->Set(pref_name_, value); |
| 75 writing_pref_ = false; | 76 writing_pref_ = false; |
| 76 } | 77 } |
| 77 | 78 |
| 78 } // namespace cronet | 79 } // namespace cronet |
| OLD | NEW |