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

Side by Side Diff: base/prefs/pref_member.cc

Issue 491753003: Domain Reliability: Don't upload when metrics reporting is off. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Block uploads in uploader, not dispatcher Created 6 years, 4 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 | Annotate | Revision Log
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 "base/prefs/pref_member.h" 5 #include "base/prefs/pref_member.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/value_conversions.h" 11 #include "base/value_conversions.h"
12 12
13 using base::MessageLoopProxy; 13 using base::MessageLoopProxy;
14 using base::SingleThreadTaskRunner;
14 15
15 namespace subtle { 16 namespace subtle {
16 17
17 PrefMemberBase::PrefMemberBase() 18 PrefMemberBase::PrefMemberBase()
18 : prefs_(NULL), 19 : prefs_(NULL),
19 setting_value_(false) { 20 setting_value_(false) {
20 } 21 }
21 22
22 PrefMemberBase::~PrefMemberBase() { 23 PrefMemberBase::~PrefMemberBase() {
23 Destroy(); 24 Destroy();
(...skipping 22 matching lines...) Expand all
46 } 47 }
47 48
48 void PrefMemberBase::Destroy() { 49 void PrefMemberBase::Destroy() {
49 if (prefs_ && !pref_name_.empty()) { 50 if (prefs_ && !pref_name_.empty()) {
50 prefs_->RemovePrefObserver(pref_name_.c_str(), this); 51 prefs_->RemovePrefObserver(pref_name_.c_str(), this);
51 prefs_ = NULL; 52 prefs_ = NULL;
52 } 53 }
53 } 54 }
54 55
55 void PrefMemberBase::MoveToThread( 56 void PrefMemberBase::MoveToThread(
56 const scoped_refptr<MessageLoopProxy>& message_loop) { 57 const scoped_refptr<SingleThreadTaskRunner>& message_loop) {
57 VerifyValuePrefName(); 58 VerifyValuePrefName();
58 // Load the value from preferences if it hasn't been loaded so far. 59 // Load the value from preferences if it hasn't been loaded so far.
59 if (!internal()) 60 if (!internal())
60 UpdateValueFromPref(base::Closure()); 61 UpdateValueFromPref(base::Closure());
61 internal()->MoveToThread(message_loop); 62 internal()->MoveToThread(message_loop);
62 } 63 }
63 64
64 void PrefMemberBase::OnPreferenceChanged(PrefService* service, 65 void PrefMemberBase::OnPreferenceChanged(PrefService* service,
65 const std::string& pref_name) { 66 const std::string& pref_name) {
66 VerifyValuePrefName(); 67 VerifyValuePrefName();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool may_run = thread_loop_->PostTask( 121 bool may_run = thread_loop_->PostTask(
121 FROM_HERE, 122 FROM_HERE,
122 base::Bind(&PrefMemberBase::Internal::UpdateValue, this, 123 base::Bind(&PrefMemberBase::Internal::UpdateValue, this,
123 value.release(), is_managed, is_user_modifiable, 124 value.release(), is_managed, is_user_modifiable,
124 closure_runner.Release())); 125 closure_runner.Release()));
125 DCHECK(may_run); 126 DCHECK(may_run);
126 } 127 }
127 } 128 }
128 129
129 void PrefMemberBase::Internal::MoveToThread( 130 void PrefMemberBase::Internal::MoveToThread(
130 const scoped_refptr<MessageLoopProxy>& message_loop) { 131 const scoped_refptr<SingleThreadTaskRunner>& message_loop) {
131 CheckOnCorrectThread(); 132 CheckOnCorrectThread();
132 thread_loop_ = message_loop; 133 thread_loop_ = message_loop;
133 } 134 }
134 135
135 bool PrefMemberVectorStringUpdate(const base::Value& value, 136 bool PrefMemberVectorStringUpdate(const base::Value& value,
136 std::vector<std::string>* string_vector) { 137 std::vector<std::string>* string_vector) {
137 if (!value.IsType(base::Value::TYPE_LIST)) 138 if (!value.IsType(base::Value::TYPE_LIST))
138 return false; 139 return false;
139 const base::ListValue* list = static_cast<const base::ListValue*>(&value); 140 const base::ListValue* list = static_cast<const base::ListValue*>(&value);
140 141
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 base::ListValue list_value; 218 base::ListValue list_value;
218 list_value.AppendStrings(value); 219 list_value.AppendStrings(value);
219 prefs()->Set(pref_name().c_str(), list_value); 220 prefs()->Set(pref_name().c_str(), list_value);
220 } 221 }
221 222
222 template <> 223 template <>
223 bool PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal( 224 bool PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal(
224 const base::Value& value) const { 225 const base::Value& value) const {
225 return subtle::PrefMemberVectorStringUpdate(value, &value_); 226 return subtle::PrefMemberVectorStringUpdate(value, &value_);
226 } 227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698