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

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

Issue 290083006: Store a stacktrace of PrefService destruction in PrefChangeRegistrar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor improvements 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
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_service.h" 5 #include "base/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 // TODO(battre): Delete this. See crbug.com/373435.
11 #include "base/debug/stack_trace.h"
10 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
14 #include "base/prefs/default_pref_store.h" 16 #include "base/prefs/default_pref_store.h"
15 #include "base/prefs/pref_notifier_impl.h" 17 #include "base/prefs/pref_notifier_impl.h"
16 #include "base/prefs/pref_registry.h" 18 #include "base/prefs/pref_registry.h"
17 #include "base/prefs/pref_value_store.h" 19 #include "base/prefs/pref_value_store.h"
18 #include "base/stl_util.h" 20 #include "base/stl_util.h"
19 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 user_pref_store_(user_prefs), 54 user_pref_store_(user_prefs),
53 read_error_callback_(read_error_callback) { 55 read_error_callback_(read_error_callback) {
54 pref_notifier_->SetPrefService(this); 56 pref_notifier_->SetPrefService(this);
55 57
56 InitFromStorage(async); 58 InitFromStorage(async);
57 } 59 }
58 60
59 PrefService::~PrefService() { 61 PrefService::~PrefService() {
60 DCHECK(CalledOnValidThread()); 62 DCHECK(CalledOnValidThread());
61 63
64 // TODO(battre): Remove the following code. It's purpose is to understand
65 // whether a crash in PrefChangeRegistrar::~PrefChangeRegistrar() is caused
66 // by a PrefService already being dead. See crbug.com/373435.
67 std::string stacktrace = base::debug::StackTrace().ToString();
68 pref_notifier_->SetPrefServiceDestructionTrace(stacktrace);
69
62 // Reset pointers so accesses after destruction reliably crash. 70 // Reset pointers so accesses after destruction reliably crash.
63 pref_value_store_.reset(); 71 pref_value_store_.reset();
64 pref_registry_ = NULL; 72 pref_registry_ = NULL;
65 user_pref_store_ = NULL; 73 user_pref_store_ = NULL;
66 pref_notifier_.reset(); 74 pref_notifier_.reset();
67 } 75 }
68 76
69 void PrefService::InitFromStorage(bool async) { 77 void PrefService::InitFromStorage(bool async) {
70 if (user_pref_store_->IsInitializationComplete()) { 78 if (user_pref_store_->IsInitializationComplete()) {
71 read_error_callback_.Run(user_pref_store_->GetReadError()); 79 read_error_callback_.Run(user_pref_store_->GetReadError());
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 DCHECK(found_value->IsType(default_type)); 554 DCHECK(found_value->IsType(default_type));
547 return found_value; 555 return found_value;
548 } else { 556 } else {
549 // Every registered preference has at least a default value. 557 // Every registered preference has at least a default value.
550 NOTREACHED() << "no valid value found for registered pref " << path; 558 NOTREACHED() << "no valid value found for registered pref " << path;
551 } 559 }
552 } 560 }
553 561
554 return NULL; 562 return NULL;
555 } 563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698