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

Side by Side Diff: trunk/src/base/prefs/pref_change_registrar.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_change_registrar.h ('k') | trunk/src/base/prefs/pref_member.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_change_registrar.h" 5 #include "base/prefs/pref_change_registrar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 // TODO(battre): Delete this. See crbug.com/373435.
9 #include "base/debug/alias.h"
10 #include "base/logging.h" 8 #include "base/logging.h"
11 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
12 10
13 PrefChangeRegistrar::PrefChangeRegistrar() : service_(NULL) {} 11 PrefChangeRegistrar::PrefChangeRegistrar() : service_(NULL) {}
14 12
15 PrefChangeRegistrar::~PrefChangeRegistrar() { 13 PrefChangeRegistrar::~PrefChangeRegistrar() {
16 // If you see an invalid memory access in this destructor, this 14 // If you see an invalid memory access in this destructor, this
17 // PrefChangeRegistrar might be subscribed to an OffTheRecordProfileImpl that 15 // PrefChangeRegistrar might be subscribed to an OffTheRecordProfileImpl that
18 // has been destroyed. This should not happen any more but be warned. 16 // has been destroyed. This should not happen any more but be warned.
19 // Feel free to contact battre@chromium.org in case this happens. 17 // Feel free to contact battre@chromium.org in case this happens.
(...skipping 23 matching lines...) Expand all
43 } 41 }
44 42
45 void PrefChangeRegistrar::Remove(const char* path) { 43 void PrefChangeRegistrar::Remove(const char* path) {
46 DCHECK(IsObserved(path)); 44 DCHECK(IsObserved(path));
47 45
48 observers_.erase(path); 46 observers_.erase(path);
49 service_->RemovePrefObserver(path, this); 47 service_->RemovePrefObserver(path, this);
50 } 48 }
51 49
52 void PrefChangeRegistrar::RemoveAll() { 50 void PrefChangeRegistrar::RemoveAll() {
53 // TODO(battre): Delete this. See crbug.com/373435.
54 if (!observers_.empty() && !pref_service_destruction_.empty()) {
55 // The PrefService is already destroyed, so the following call to
56 // service_->RemovePrefObserver would crash anyway. When the PrefService
57 // was destroyed, it stored a stack trace of the destruction in
58 // pref_service_destruction_. We save this on the stack in the minidump to
59 // understand what happens.
60 char tmp[2048] = {};
61 strncat(tmp, pref_service_destruction_.c_str(), sizeof(tmp) - 1u);
62 base::debug::Alias(tmp);
63 CHECK(false) << tmp;
64 }
65
66 for (ObserverMap::const_iterator it = observers_.begin(); 51 for (ObserverMap::const_iterator it = observers_.begin();
67 it != observers_.end(); ++it) { 52 it != observers_.end(); ++it) {
68 service_->RemovePrefObserver(it->first.c_str(), this); 53 service_->RemovePrefObserver(it->first.c_str(), this);
69 } 54 }
70 55
71 observers_.clear(); 56 observers_.clear();
72 } 57 }
73 58
74 bool PrefChangeRegistrar::IsEmpty() const { 59 bool PrefChangeRegistrar::IsEmpty() const {
75 return observers_.empty(); 60 return observers_.empty();
(...skipping 13 matching lines...) Expand all
89 } 74 }
90 return false; 75 return false;
91 } 76 }
92 77
93 void PrefChangeRegistrar::OnPreferenceChanged(PrefService* service, 78 void PrefChangeRegistrar::OnPreferenceChanged(PrefService* service,
94 const std::string& pref) { 79 const std::string& pref) {
95 if (IsObserved(pref)) 80 if (IsObserved(pref))
96 observers_[pref].Run(pref); 81 observers_[pref].Run(pref);
97 } 82 }
98 83
99 // TODO(battre): Delete this. See crbug.com/373435.
100 void PrefChangeRegistrar::SetPrefServiceDestructionTrace(
101 const std::string& stack_trace) {
102 pref_service_destruction_ = stack_trace;
103 }
104
105 void PrefChangeRegistrar::InvokeUnnamedCallback(const base::Closure& callback, 84 void PrefChangeRegistrar::InvokeUnnamedCallback(const base::Closure& callback,
106 const std::string& pref_name) { 85 const std::string& pref_name) {
107 callback.Run(); 86 callback.Run();
108 } 87 }
109 88
110 PrefService* PrefChangeRegistrar::prefs() { 89 PrefService* PrefChangeRegistrar::prefs() {
111 return service_; 90 return service_;
112 } 91 }
113 92
114 const PrefService* PrefChangeRegistrar::prefs() const { 93 const PrefService* PrefChangeRegistrar::prefs() const {
115 return service_; 94 return service_;
116 } 95 }
OLDNEW
« no previous file with comments | « trunk/src/base/prefs/pref_change_registrar.h ('k') | trunk/src/base/prefs/pref_member.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698