[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / third_party / libaddressinput / chromium / chrome_storage_impl.h
blobb68c72bacbf36174a860dbec494bd341aaf8e8c8
1 // Copyright 2014 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.
5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
8 #include <list>
9 #include <string>
11 #include "base/memory/scoped_vector.h"
12 #include "base/prefs/pref_store.h"
13 #include "base/scoped_observer.h"
14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
16 class WriteablePrefStore;
18 namespace autofill {
20 // An implementation of the Storage interface which passes through to an
21 // underlying WriteablePrefStore.
22 class ChromeStorageImpl : public ::i18n::addressinput::Storage,
23 public PrefStore::Observer {
24 public:
25 // |store| must outlive |this|.
26 explicit ChromeStorageImpl(WriteablePrefStore* store);
27 virtual ~ChromeStorageImpl();
29 // ::i18n::addressinput::Storage implementation.
30 virtual void Put(const std::string& key, std::string* data) OVERRIDE;
31 virtual void Get(const std::string& key, const Callback& data_ready)
32 const OVERRIDE;
34 // PrefStore::Observer implementation.
35 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE;
36 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE;
38 private:
39 struct Request {
40 Request(const std::string& key, const Callback& callback);
42 std::string key;
43 const Callback& callback;
46 // Non-const version of Get().
47 void DoGet(const std::string& key, const Callback& data_ready);
49 WriteablePrefStore* backing_store_; // weak
51 // Get requests that haven't yet been serviced.
52 ScopedVector<Request> outstanding_requests_;
54 ScopedObserver<PrefStore, ChromeStorageImpl> scoped_observer_;
56 DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl);
59 } // namespace autofill
61 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_