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

Side by Side Diff: chrome/common/json_pref_store.h

Issue 10344007: Use worker pool for IO in JsonPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « chrome/common/important_file_writer.cc ('k') | chrome/common/json_pref_store.cc » ('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) 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 CHROME_COMMON_JSON_PREF_STORE_H_ 5 #ifndef CHROME_COMMON_JSON_PREF_STORE_H_
6 #define CHROME_COMMON_JSON_PREF_STORE_H_ 6 #define CHROME_COMMON_JSON_PREF_STORE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "chrome/common/important_file_writer.h" 17 #include "chrome/common/important_file_writer.h"
18 #include "chrome/common/persistent_pref_store.h" 18 #include "chrome/common/persistent_pref_store.h"
19 19
20 namespace base { 20 namespace base {
21 class DictionaryValue; 21 class DictionaryValue;
22 class MessageLoopProxy; 22 class SequencedTaskRunner;
23 class Value; 23 class Value;
24 } 24 }
25 25
26 class FilePath; 26 class FilePath;
27 27
28 // A writable PrefStore implementation that is used for user preferences. 28 // A writable PrefStore implementation that is used for user preferences.
29 class JsonPrefStore : public PersistentPrefStore, 29 class JsonPrefStore : public PersistentPrefStore,
30 public ImportantFileWriter::DataSerializer { 30 public ImportantFileWriter::DataSerializer {
31 public: 31 public:
32 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which 32 // |blocking_task_runner| is the SequencedTaskRunner on which file
33 // file I/O can be done. 33 // I/O can be done.
34 JsonPrefStore(const FilePath& pref_filename, 34 JsonPrefStore(const FilePath& pref_filename,
35 base::MessageLoopProxy* file_message_loop_proxy); 35 base::SequencedTaskRunner* blocking_task_runner);
36 36
37 // PrefStore overrides: 37 // PrefStore overrides:
38 virtual ReadResult GetValue(const std::string& key, 38 virtual ReadResult GetValue(const std::string& key,
39 const base::Value** result) const OVERRIDE; 39 const base::Value** result) const OVERRIDE;
40 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; 40 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE;
41 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; 41 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE;
42 virtual size_t NumberOfObservers() const OVERRIDE; 42 virtual size_t NumberOfObservers() const OVERRIDE;
43 virtual bool IsInitializationComplete() const OVERRIDE; 43 virtual bool IsInitializationComplete() const OVERRIDE;
44 44
45 // PersistentPrefStore overrides: 45 // PersistentPrefStore overrides:
(...skipping 17 matching lines...) Expand all
63 // (read: do not call it manually). 63 // (read: do not call it manually).
64 void OnFileRead(base::Value* value_owned, PrefReadError error, bool no_dir); 64 void OnFileRead(base::Value* value_owned, PrefReadError error, bool no_dir);
65 65
66 private: 66 private:
67 virtual ~JsonPrefStore(); 67 virtual ~JsonPrefStore();
68 68
69 // ImportantFileWriter::DataSerializer overrides: 69 // ImportantFileWriter::DataSerializer overrides:
70 virtual bool SerializeData(std::string* output) OVERRIDE; 70 virtual bool SerializeData(std::string* output) OVERRIDE;
71 71
72 FilePath path_; 72 FilePath path_;
73 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; 73 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
74 74
75 scoped_ptr<base::DictionaryValue> prefs_; 75 scoped_ptr<base::DictionaryValue> prefs_;
76 76
77 bool read_only_; 77 bool read_only_;
78 78
79 // Helper for safely writing pref data. 79 // Helper for safely writing pref data.
80 ImportantFileWriter writer_; 80 ImportantFileWriter writer_;
81 81
82 ObserverList<PrefStore::Observer, true> observers_; 82 ObserverList<PrefStore::Observer, true> observers_;
83 83
84 scoped_ptr<ReadErrorDelegate> error_delegate_; 84 scoped_ptr<ReadErrorDelegate> error_delegate_;
85 85
86 bool initialized_; 86 bool initialized_;
87 PrefReadError read_error_; 87 PrefReadError read_error_;
88 88
89 std::set<std::string> keys_need_empty_value_; 89 std::set<std::string> keys_need_empty_value_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); 91 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore);
92 }; 92 };
93 93
94 #endif // CHROME_COMMON_JSON_PREF_STORE_H_ 94 #endif // CHROME_COMMON_JSON_PREF_STORE_H_
OLDNEW
« no previous file with comments | « chrome/common/important_file_writer.cc ('k') | chrome/common/json_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698