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

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

Issue 90563003: Fix a race condition in preference metric reporting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to Gab's comments. Created 7 years 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 | « 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/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/important_file_writer.h" 14 #include "base/files/important_file_writer.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop_proxy.h" 16 #include "base/message_loop/message_loop_proxy.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/prefs/base_prefs_export.h" 18 #include "base/prefs/base_prefs_export.h"
19 #include "base/prefs/persistent_pref_store.h" 19 #include "base/prefs/persistent_pref_store.h"
20 20
21 class PrefFilter;
gab 2013/12/06 17:23:38 Don't you need the full type here since you declar
erikwright (departed) 2013/12/06 19:00:47 The latter. It's the call to scoped_ptr<T>::~scope
22
21 namespace base { 23 namespace base {
22 class DictionaryValue; 24 class DictionaryValue;
23 class FilePath; 25 class FilePath;
24 class SequencedWorkerPool; 26 class SequencedWorkerPool;
25 class SequencedTaskRunner; 27 class SequencedTaskRunner;
26 class Value; 28 class Value;
27 } 29 }
28 30
29 31
30 // A writable PrefStore implementation that is used for user preferences. 32 // A writable PrefStore implementation that is used for user preferences.
31 class BASE_PREFS_EXPORT JsonPrefStore 33 class BASE_PREFS_EXPORT JsonPrefStore
32 : public PersistentPrefStore, 34 : public PersistentPrefStore,
33 public base::ImportantFileWriter::DataSerializer { 35 public base::ImportantFileWriter::DataSerializer {
34 public: 36 public:
35 // Returns instance of SequencedTaskRunner which guarantees that file 37 // Returns instance of SequencedTaskRunner which guarantees that file
36 // operations on the same file will be executed in sequenced order. 38 // operations on the same file will be executed in sequenced order.
37 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile( 39 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile(
38 const base::FilePath& pref_filename, 40 const base::FilePath& pref_filename,
39 base::SequencedWorkerPool* worker_pool); 41 base::SequencedWorkerPool* worker_pool);
40 42
41 // |sequenced_task_runner| is must be a shutdown-blocking task runner, ideally 43 // |sequenced_task_runner| is must be a shutdown-blocking task runner, ideally
42 // created by GetTaskRunnerForFile() method above. 44 // created by GetTaskRunnerForFile() method above.
43 JsonPrefStore(const base::FilePath& pref_filename, 45 JsonPrefStore(const base::FilePath& pref_filename,
44 base::SequencedTaskRunner* sequenced_task_runner); 46 base::SequencedTaskRunner* sequenced_task_runner,
47 scoped_ptr<PrefFilter> pref_filter);
45 48
46 // PrefStore overrides: 49 // PrefStore overrides:
47 virtual bool GetValue(const std::string& key, 50 virtual bool GetValue(const std::string& key,
48 const base::Value** result) const OVERRIDE; 51 const base::Value** result) const OVERRIDE;
49 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; 52 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE;
50 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; 53 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE;
51 virtual bool HasObservers() const OVERRIDE; 54 virtual bool HasObservers() const OVERRIDE;
52 virtual bool IsInitializationComplete() const OVERRIDE; 55 virtual bool IsInitializationComplete() const OVERRIDE;
53 56
54 // PersistentPrefStore overrides: 57 // PersistentPrefStore overrides:
(...skipping 26 matching lines...) Expand all
81 base::FilePath path_; 84 base::FilePath path_;
82 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; 85 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
83 86
84 scoped_ptr<base::DictionaryValue> prefs_; 87 scoped_ptr<base::DictionaryValue> prefs_;
85 88
86 bool read_only_; 89 bool read_only_;
87 90
88 // Helper for safely writing pref data. 91 // Helper for safely writing pref data.
89 base::ImportantFileWriter writer_; 92 base::ImportantFileWriter writer_;
90 93
94 scoped_ptr<PrefFilter> pref_filter_;
91 ObserverList<PrefStore::Observer, true> observers_; 95 ObserverList<PrefStore::Observer, true> observers_;
92 96
93 scoped_ptr<ReadErrorDelegate> error_delegate_; 97 scoped_ptr<ReadErrorDelegate> error_delegate_;
94 98
95 bool initialized_; 99 bool initialized_;
96 PrefReadError read_error_; 100 PrefReadError read_error_;
97 101
98 std::set<std::string> keys_need_empty_value_; 102 std::set<std::string> keys_need_empty_value_;
99 103
100 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); 104 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore);
101 }; 105 };
102 106
103 #endif // BASE_PREFS_JSON_PREF_STORE_H_ 107 #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