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

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

Issue 289373006: Revert 271416 "Store a stacktrace of PrefService destruction in ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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
« no previous file with comments | « trunk/src/base/prefs/pref_member.h ('k') | trunk/src/base/prefs/pref_notifier.h » ('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 (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 // TODO(battre): Delete this. See crbug.com/373435.
10 #include "base/debug/alias.h"
11 #include "base/location.h" 9 #include "base/location.h"
12 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
13 #include "base/value_conversions.h" 11 #include "base/value_conversions.h"
14 12
15 using base::MessageLoopProxy; 13 using base::MessageLoopProxy;
16 14
17 namespace subtle { 15 namespace subtle {
18 16
19 PrefMemberBase::PrefMemberBase() 17 PrefMemberBase::PrefMemberBase()
20 : prefs_(NULL), 18 : prefs_(NULL),
(...skipping 21 matching lines...) Expand all
42 // Check that the preference is registered. 40 // Check that the preference is registered.
43 DCHECK(prefs_->FindPreference(pref_name_.c_str())) 41 DCHECK(prefs_->FindPreference(pref_name_.c_str()))
44 << pref_name << " not registered."; 42 << pref_name << " not registered.";
45 43
46 // Add ourselves as a pref observer so we can keep our local value in sync. 44 // Add ourselves as a pref observer so we can keep our local value in sync.
47 prefs_->AddPrefObserver(pref_name, this); 45 prefs_->AddPrefObserver(pref_name, this);
48 } 46 }
49 47
50 void PrefMemberBase::Destroy() { 48 void PrefMemberBase::Destroy() {
51 if (prefs_ && !pref_name_.empty()) { 49 if (prefs_ && !pref_name_.empty()) {
52 // TODO(battre): Delete this. See crbug.com/373435.
53 if (!pref_service_destruction_.empty()) {
54 // The PrefService is already destroyed, so the following call to
55 // service_->RemovePrefObserver would crash anyway. When the PrefService
56 // was destroyed, it stored a stack trace of the destruction in
57 // pref_service_destruction_. We save this on the stack in the minidump to
58 // understand what happens.
59 char tmp[2048] = {};
60 strncat(tmp, pref_service_destruction_.c_str(), sizeof(tmp) - 1u);
61 base::debug::Alias(tmp);
62 CHECK(false) << tmp;
63 }
64 prefs_->RemovePrefObserver(pref_name_.c_str(), this); 50 prefs_->RemovePrefObserver(pref_name_.c_str(), this);
65 prefs_ = NULL; 51 prefs_ = NULL;
66 } 52 }
67 } 53 }
68 54
69 void PrefMemberBase::MoveToThread( 55 void PrefMemberBase::MoveToThread(
70 const scoped_refptr<MessageLoopProxy>& message_loop) { 56 const scoped_refptr<MessageLoopProxy>& message_loop) {
71 VerifyValuePrefName(); 57 VerifyValuePrefName();
72 // Load the value from preferences if it hasn't been loaded so far. 58 // Load the value from preferences if it hasn't been loaded so far.
73 if (!internal()) 59 if (!internal())
74 UpdateValueFromPref(base::Closure()); 60 UpdateValueFromPref(base::Closure());
75 internal()->MoveToThread(message_loop); 61 internal()->MoveToThread(message_loop);
76 } 62 }
77 63
78 void PrefMemberBase::OnPreferenceChanged(PrefService* service, 64 void PrefMemberBase::OnPreferenceChanged(PrefService* service,
79 const std::string& pref_name) { 65 const std::string& pref_name) {
80 VerifyValuePrefName(); 66 VerifyValuePrefName();
81 UpdateValueFromPref((!setting_value_ && !observer_.is_null()) ? 67 UpdateValueFromPref((!setting_value_ && !observer_.is_null()) ?
82 base::Bind(observer_, pref_name) : base::Closure()); 68 base::Bind(observer_, pref_name) : base::Closure());
83 } 69 }
84 70
85 // TODO(battre): Delete this. See crbug.com/373435.
86 void PrefMemberBase::SetPrefServiceDestructionTrace(
87 const std::string& stack_trace) {
88 pref_service_destruction_ = stack_trace;
89 }
90
91 void PrefMemberBase::UpdateValueFromPref(const base::Closure& callback) const { 71 void PrefMemberBase::UpdateValueFromPref(const base::Closure& callback) const {
92 VerifyValuePrefName(); 72 VerifyValuePrefName();
93 const PrefService::Preference* pref = 73 const PrefService::Preference* pref =
94 prefs_->FindPreference(pref_name_.c_str()); 74 prefs_->FindPreference(pref_name_.c_str());
95 DCHECK(pref); 75 DCHECK(pref);
96 if (!internal()) 76 if (!internal())
97 CreateInternal(); 77 CreateInternal();
98 internal()->UpdateValue(pref->GetValue()->DeepCopy(), 78 internal()->UpdateValue(pref->GetValue()->DeepCopy(),
99 pref->IsManaged(), 79 pref->IsManaged(),
100 pref->IsUserModifiable(), 80 pref->IsUserModifiable(),
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 base::ListValue list_value; 217 base::ListValue list_value;
238 list_value.AppendStrings(value); 218 list_value.AppendStrings(value);
239 prefs()->Set(pref_name().c_str(), list_value); 219 prefs()->Set(pref_name().c_str(), list_value);
240 } 220 }
241 221
242 template <> 222 template <>
243 bool PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal( 223 bool PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal(
244 const base::Value& value) const { 224 const base::Value& value) const {
245 return subtle::PrefMemberVectorStringUpdate(value, &value_); 225 return subtle::PrefMemberVectorStringUpdate(value, &value_);
246 } 226 }
OLDNEW
« no previous file with comments | « trunk/src/base/prefs/pref_member.h ('k') | trunk/src/base/prefs/pref_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698