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

Side by Side Diff: base/prefs/json_pref_store.h

Issue 1083603002: Add histograms to record the number of writes to the prefs file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | base/prefs/json_pref_store.cc » ('j') | base/prefs/json_pref_store.cc » ('J')
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 #ifndef BASE_PREFS_JSON_PREF_STORE_H_ 5 #ifndef BASE_PREFS_JSON_PREF_STORE_H_
6 #define BASE_PREFS_JSON_PREF_STORE_H_ 6 #define BASE_PREFS_JSON_PREF_STORE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/important_file_writer.h" 15 #include "base/files/important_file_writer.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
18 #include "base/message_loop/message_loop_proxy.h" 19 #include "base/message_loop/message_loop_proxy.h"
19 #include "base/observer_list.h" 20 #include "base/observer_list.h"
20 #include "base/prefs/base_prefs_export.h" 21 #include "base/prefs/base_prefs_export.h"
21 #include "base/prefs/persistent_pref_store.h" 22 #include "base/prefs/persistent_pref_store.h"
22 #include "base/threading/non_thread_safe.h" 23 #include "base/threading/non_thread_safe.h"
23 24
24 class PrefFilter; 25 class PrefFilter;
25 26
26 namespace base { 27 namespace base {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Just like RemoveValue(), but doesn't notify observers. Used when doing some 92 // Just like RemoveValue(), but doesn't notify observers. Used when doing some
92 // cleanup that shouldn't otherwise alert observers. 93 // cleanup that shouldn't otherwise alert observers.
93 void RemoveValueSilently(const std::string& key); 94 void RemoveValueSilently(const std::string& key);
94 95
95 // Registers |on_next_successful_write| to be called once, on the next 96 // Registers |on_next_successful_write| to be called once, on the next
96 // successful write event of |writer_|. 97 // successful write event of |writer_|.
97 void RegisterOnNextSuccessfulWriteCallback( 98 void RegisterOnNextSuccessfulWriteCallback(
98 const base::Closure& on_next_successful_write); 99 const base::Closure& on_next_successful_write);
99 100
100 private: 101 private:
102 class WriteCountHistogram;
103
101 ~JsonPrefStore() override; 104 ~JsonPrefStore() override;
102 105
103 // This method is called after the JSON file has been read. It then hands 106 // This method is called after the JSON file has been read. It then hands
104 // |value| (or an empty dictionary in some read error cases) to the 107 // |value| (or an empty dictionary in some read error cases) to the
105 // |pref_filter| if one is set. It also gives a callback pointing at 108 // |pref_filter| if one is set. It also gives a callback pointing at
106 // FinalizeFileRead() to that |pref_filter_| which is then responsible for 109 // FinalizeFileRead() to that |pref_filter_| which is then responsible for
107 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead() 110 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead()
108 // is invoked directly. 111 // is invoked directly.
109 void OnFileRead(scoped_ptr<ReadResult> read_result); 112 void OnFileRead(scoped_ptr<ReadResult> read_result);
110 113
(...skipping 26 matching lines...) Expand all
137 ObserverList<PrefStore::Observer, true> observers_; 140 ObserverList<PrefStore::Observer, true> observers_;
138 141
139 scoped_ptr<ReadErrorDelegate> error_delegate_; 142 scoped_ptr<ReadErrorDelegate> error_delegate_;
140 143
141 bool initialized_; 144 bool initialized_;
142 bool filtering_in_progress_; 145 bool filtering_in_progress_;
143 PrefReadError read_error_; 146 PrefReadError read_error_;
144 147
145 std::set<std::string> keys_need_empty_value_; 148 std::set<std::string> keys_need_empty_value_;
146 149
150 ScopedVector<WriteCountHistogram> write_count_histograms_;
151
147 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); 152 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore);
148 }; 153 };
149 154
150 #endif // BASE_PREFS_JSON_PREF_STORE_H_ 155 #endif // BASE_PREFS_JSON_PREF_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | base/prefs/json_pref_store.cc » ('j') | base/prefs/json_pref_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698