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

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: 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/memory/scoped_vector.h"
16 #include "base/message_loop/message_loop_proxy.h" 17 #include "base/message_loop/message_loop_proxy.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "base/prefs/base_prefs_export.h" 19 #include "base/prefs/base_prefs_export.h"
19 #include "base/prefs/persistent_pref_store.h" 20 #include "base/prefs/persistent_pref_store.h"
20 21
21 namespace base { 22 namespace base {
22 class DictionaryValue; 23 class DictionaryValue;
23 class FilePath; 24 class FilePath;
24 class SequencedWorkerPool; 25 class SequencedWorkerPool;
25 class SequencedTaskRunner; 26 class SequencedTaskRunner;
(...skipping 18 matching lines...) Expand all
44 base::SequencedTaskRunner* sequenced_task_runner); 45 base::SequencedTaskRunner* sequenced_task_runner);
45 46
46 // PrefStore overrides: 47 // PrefStore overrides:
47 virtual bool GetValue(const std::string& key, 48 virtual bool GetValue(const std::string& key,
48 const base::Value** result) const OVERRIDE; 49 const base::Value** result) const OVERRIDE;
49 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; 50 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE;
50 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; 51 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE;
51 virtual bool HasObservers() const OVERRIDE; 52 virtual bool HasObservers() const OVERRIDE;
52 virtual bool IsInitializationComplete() const OVERRIDE; 53 virtual bool IsInitializationComplete() const OVERRIDE;
53 54
55 // Adds an observer that will be automatically deregistered and destroyed by
56 // ~JsonPrefStore().
57 void AddOwnedObserver(scoped_ptr<PrefStore::Observer> observer);
gab 2013/11/27 23:43:27 #include base/prefs/pref_store.h for PrefStore::O
robertshield 2013/11/28 02:54:26 AddObserver takes a raw pointer, any reason not to
erikwright (departed) 2013/11/28 17:48:07 Because there is a transfer of ownership.
58
54 // PersistentPrefStore overrides: 59 // PersistentPrefStore overrides:
55 virtual bool GetMutableValue(const std::string& key, 60 virtual bool GetMutableValue(const std::string& key,
56 base::Value** result) OVERRIDE; 61 base::Value** result) OVERRIDE;
57 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; 62 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE;
58 virtual void SetValueSilently(const std::string& key, 63 virtual void SetValueSilently(const std::string& key,
59 base::Value* value) OVERRIDE; 64 base::Value* value) OVERRIDE;
60 virtual void RemoveValue(const std::string& key) OVERRIDE; 65 virtual void RemoveValue(const std::string& key) OVERRIDE;
61 virtual void MarkNeedsEmptyValue(const std::string& key) OVERRIDE; 66 virtual void MarkNeedsEmptyValue(const std::string& key) OVERRIDE;
62 virtual bool ReadOnly() const OVERRIDE; 67 virtual bool ReadOnly() const OVERRIDE;
63 virtual PrefReadError GetReadError() const OVERRIDE; 68 virtual PrefReadError GetReadError() const OVERRIDE;
(...skipping 18 matching lines...) Expand all
82 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; 87 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
83 88
84 scoped_ptr<base::DictionaryValue> prefs_; 89 scoped_ptr<base::DictionaryValue> prefs_;
85 90
86 bool read_only_; 91 bool read_only_;
87 92
88 // Helper for safely writing pref data. 93 // Helper for safely writing pref data.
89 base::ImportantFileWriter writer_; 94 base::ImportantFileWriter writer_;
90 95
91 ObserverList<PrefStore::Observer, true> observers_; 96 ObserverList<PrefStore::Observer, true> observers_;
97 ScopedVector<PrefStore::Observer> owned_observers_;
92 98
93 scoped_ptr<ReadErrorDelegate> error_delegate_; 99 scoped_ptr<ReadErrorDelegate> error_delegate_;
94 100
95 bool initialized_; 101 bool initialized_;
96 PrefReadError read_error_; 102 PrefReadError read_error_;
97 103
98 std::set<std::string> keys_need_empty_value_; 104 std::set<std::string> keys_need_empty_value_;
99 105
100 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); 106 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore);
101 }; 107 };
102 108
103 #endif // BASE_PREFS_JSON_PREF_STORE_H_ 109 #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