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

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

Issue 2369673004: Wire NQE Prefs to Profile (Closed)
Patch Set: ps Created 4 years, 2 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Notify |this| on the pref thread. 51 // Notify |this| on the pref thread.
52 pref_task_runner_->PostTask( 52 pref_task_runner_->PostTask(
53 FROM_HERE, 53 FROM_HERE,
54 base::Bind(&NetworkQualitiesPrefsManager:: 54 base::Bind(&NetworkQualitiesPrefsManager::
55 OnChangeInCachedNetworkQualityOnPrefThread, 55 OnChangeInCachedNetworkQualityOnPrefThread,
56 pref_weak_ptr_, network_id, cached_network_quality)); 56 pref_weak_ptr_, network_id, cached_network_quality));
57 } 57 }
58 58
59 void NetworkQualitiesPrefsManager::ShutdownOnPrefThread() { 59 void NetworkQualitiesPrefsManager::ShutdownOnPrefThread() {
60 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 60 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
61 pref_weak_ptr_factory_.InvalidateWeakPtrs();
61 pref_delegate_.reset(); 62 pref_delegate_.reset();
62 } 63 }
63 64
64 void NetworkQualitiesPrefsManager::OnChangeInCachedNetworkQualityOnPrefThread( 65 void NetworkQualitiesPrefsManager::OnChangeInCachedNetworkQualityOnPrefThread(
65 const nqe::internal::NetworkID& network_id, 66 const nqe::internal::NetworkID& network_id,
66 const nqe::internal::CachedNetworkQuality& cached_network_quality) { 67 const nqe::internal::CachedNetworkQuality& cached_network_quality) {
67 // The prefs can only be written on the pref thread. 68 // The prefs can only be written on the pref thread.
68 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 69 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
69 70
70 base::DictionaryValue dictionary_value; 71 base::DictionaryValue dictionary_value;
71 dictionary_value.SetString( 72 dictionary_value.SetString(
72 network_id.ToString(), 73 network_id.ToString(),
73 GetNameForEffectiveConnectionType( 74 GetNameForEffectiveConnectionType(
74 cached_network_quality.effective_connection_type())); 75 cached_network_quality.effective_connection_type()));
75 76
76 // Notify the pref delegate so that it updates the prefs on the disk. 77 // Notify the pref delegate so that it updates the prefs on the disk.
77 pref_delegate_->SetDictionaryValue(dictionary_value); 78 pref_delegate_->SetDictionaryValue(dictionary_value);
78 } 79 }
79 80
80 } // namespace net 81 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698