OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ | |
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ | |
7 | |
8 #include <libaddressinput/storage.h> | |
9 #include <libaddressinput/util/scoped_ptr.h> | |
please use gerrit instead
2013/12/20 02:04:40
As this is not a part of libaddressinput, you can
Evan Stade
2013/12/20 03:21:56
Done.
| |
10 | |
11 #include <list> | |
12 #include <string> | |
13 | |
14 #include "base/prefs/pref_store.h" | |
15 #include "base/scoped_observer.h" | |
16 | |
17 class WriteablePrefStore; | |
18 | |
19 namespace i18n { | |
20 namespace addressinput { | |
please use gerrit instead
2013/12/20 02:04:40
As this is not a part of libaddressinput, your cla
Evan Stade
2013/12/20 03:21:56
Done.
| |
21 | |
22 // An implementation of the Storage interface which passes through to an | |
23 // underlying WriteablePrefStore. | |
24 class ChromeStorageImpl : public Storage, | |
25 public PrefStore::Observer { | |
26 public: | |
27 // |store| must outlive |this|. | |
28 ChromeStorageImpl(WriteablePrefStore* store); | |
please use gerrit instead
2013/12/20 02:04:40
explicit
Evan Stade
2013/12/20 03:21:56
Done.
| |
29 virtual ~ChromeStorageImpl(); | |
30 | |
31 // i18n::addressinput::Storage implementation. | |
32 virtual void Put(const std::string& key, const std::string& data) OVERRIDE; | |
33 virtual void Get(const std::string& key, | |
34 scoped_ptr<Storage::Callback> data_ready) const OVERRIDE; | |
35 | |
36 // PrefStore::Observer implementation. | |
37 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; | |
38 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; | |
39 | |
40 private: | |
41 struct Request { | |
42 Request(const std::string& key, | |
43 scoped_ptr<Storage::Callback> callback); | |
44 | |
45 std::string key; | |
46 scoped_ptr<Storage::Callback> callback; | |
47 }; | |
48 | |
49 // Non-const version of Get(). | |
50 void DoGet(const std::string& key, scoped_ptr<Storage::Callback> data_ready); | |
51 | |
52 WriteablePrefStore* backing_store_; // weak | |
53 | |
54 // Get requests that haven't yet been serviced. | |
55 std::list<scoped_ptr<Request> > outstanding_requests_; | |
56 | |
57 ScopedObserver<WriteablePrefStore, ChromeStorageImpl> scoped_observer_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl); | |
60 }; | |
61 | |
62 } // namespace i18n | |
63 } // namespace addressinput | |
64 | |
65 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ | |
OLD | NEW |