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

Side by Side Diff: net/nqe/network_qualities_prefs_manager.cc

Issue 2700643002: Increase the NQE cache size from 3 to 10 (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | net/nqe/network_qualities_prefs_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "net/nqe/network_quality_estimator.h" 15 #include "net/nqe/network_quality_estimator.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace { 19 namespace {
20 20
21 // Maximum size of the prefs that hold the qualities of different networks. 21 // Maximum size of the prefs that hold the qualities of different networks.
22 static const size_t kMaxCacheSize = 3u; 22 static const size_t kMaxCacheSize = 10u;
xunjieli 2017/02/16 18:59:57 nit: Can you add a comment here on why big an entr
tbansal1 2017/02/16 21:53:47 Done.
23 23
24 // Parses |value| into a map of NetworkIDs and CachedNetworkQualities, 24 // Parses |value| into a map of NetworkIDs and CachedNetworkQualities,
25 // and returns the map. 25 // and returns the map.
26 ParsedPrefs ConvertDictionaryValueToMap(const base::DictionaryValue* value) { 26 ParsedPrefs ConvertDictionaryValueToMap(const base::DictionaryValue* value) {
27 ParsedPrefs read_prefs; 27 ParsedPrefs read_prefs;
28 28
29 DCHECK_GE(kMaxCacheSize, value->size()); 29 DCHECK_GE(kMaxCacheSize, value->size());
30 30
31 for (base::DictionaryValue::Iterator it(*value); !it.IsAtEnd(); 31 for (base::DictionaryValue::Iterator it(*value); !it.IsAtEnd();
32 it.Advance()) { 32 it.Advance()) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 ParsedPrefs NetworkQualitiesPrefsManager::ForceReadPrefsForTesting() const { 165 ParsedPrefs NetworkQualitiesPrefsManager::ForceReadPrefsForTesting() const {
166 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 166 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
167 std::unique_ptr<base::DictionaryValue> value( 167 std::unique_ptr<base::DictionaryValue> value(
168 pref_delegate_->GetDictionaryValue()); 168 pref_delegate_->GetDictionaryValue());
169 return ConvertDictionaryValueToMap(value.get()); 169 return ConvertDictionaryValueToMap(value.get());
170 } 170 }
171 171
172 } // namespace net 172 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/nqe/network_qualities_prefs_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698