| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "net/nqe/network_qualities_prefs_manager.h" | 5 #include "net/nqe/network_qualities_prefs_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 return read_prefs; | 50 return read_prefs; |
| 51 } | 51 } |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 NetworkQualitiesPrefsManager::NetworkQualitiesPrefsManager( | 55 NetworkQualitiesPrefsManager::NetworkQualitiesPrefsManager( |
| 56 std::unique_ptr<PrefDelegate> pref_delegate) | 56 std::unique_ptr<PrefDelegate> pref_delegate) |
| 57 : pref_delegate_(std::move(pref_delegate)), | 57 : pref_delegate_(std::move(pref_delegate)), |
| 58 pref_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 58 pref_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 59 prefs_(pref_delegate_->GetDictionaryValue().CreateDeepCopy()), | 59 prefs_(pref_delegate_->GetDictionaryValue()), |
| 60 network_quality_estimator_(nullptr), | 60 network_quality_estimator_(nullptr), |
| 61 read_prefs_startup_(ConvertDictionaryValueToMap(prefs_.get())), | 61 read_prefs_startup_(ConvertDictionaryValueToMap(prefs_.get())), |
| 62 pref_weak_ptr_factory_(this) { | 62 pref_weak_ptr_factory_(this) { |
| 63 DCHECK(pref_delegate_); | 63 DCHECK(pref_delegate_); |
| 64 DCHECK_GE(kMaxCacheSize, prefs_->size()); | 64 DCHECK_GE(kMaxCacheSize, prefs_->size()); |
| 65 | 65 |
| 66 pref_weak_ptr_ = pref_weak_ptr_factory_.GetWeakPtr(); | 66 pref_weak_ptr_ = pref_weak_ptr_factory_.GetWeakPtr(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 NetworkQualitiesPrefsManager::~NetworkQualitiesPrefsManager() { | 69 NetworkQualitiesPrefsManager::~NetworkQualitiesPrefsManager() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 DCHECK_GE(kMaxCacheSize, prefs_->size()); | 147 DCHECK_GE(kMaxCacheSize, prefs_->size()); |
| 148 | 148 |
| 149 // Notify the pref delegate so that it updates the prefs on the disk. | 149 // Notify the pref delegate so that it updates the prefs on the disk. |
| 150 pref_delegate_->SetDictionaryValue(*prefs_); | 150 pref_delegate_->SetDictionaryValue(*prefs_); |
| 151 } | 151 } |
| 152 | 152 |
| 153 ParsedPrefs NetworkQualitiesPrefsManager::ForceReadPrefsForTesting() const { | 153 ParsedPrefs NetworkQualitiesPrefsManager::ForceReadPrefsForTesting() const { |
| 154 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 154 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
| 155 std::unique_ptr<base::DictionaryValue> value( | 155 std::unique_ptr<base::DictionaryValue> value( |
| 156 pref_delegate_->GetDictionaryValue().CreateDeepCopy()); | 156 pref_delegate_->GetDictionaryValue()); |
| 157 return ConvertDictionaryValueToMap(value.get()); | 157 return ConvertDictionaryValueToMap(value.get()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace net | 160 } // namespace net |
| OLD | NEW |