Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / third_party / libaddressinput / chromium / chrome_storage_impl.h
blob5ee657b139c96000c994679558875f71f8374420
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/chromium/cpp/include/libaddressinput/storage.h"
15 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/util/scoped_ptr.h"
17 class WriteablePrefStore;
19 namespace autofill {
21 // An implementation of the Storage interface which passes through to an
22 // underlying WriteablePrefStore.
23 class ChromeStorageImpl : public ::i18n::addressinput::Storage,
24 public PrefStore::Observer {
25 public:
26 // |store| must outlive |this|.
27 explicit ChromeStorageImpl(WriteablePrefStore* store);
28 virtual ~ChromeStorageImpl();
30 // ::i18n::addressinput::Storage implementation.
31 virtual void Put(const std::string& key, scoped_ptr<std::string> data)
32 OVERRIDE;
33 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready)
34 const OVERRIDE;
36 // PrefStore::Observer implementation.
37 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE;
38 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE;
40 private:
41 struct Request {
42 Request(const std::string& key, scoped_ptr<Callback> callback);
44 std::string key;
45 scoped_ptr<Callback> callback;
48 // Non-const version of Get().
49 void DoGet(const std::string& key, scoped_ptr<Callback> data_ready);
51 WriteablePrefStore* backing_store_; // weak
53 // Get requests that haven't yet been serviced.
54 ScopedVector<Request> outstanding_requests_;
56 ScopedObserver<PrefStore, ChromeStorageImpl> scoped_observer_;
58 DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl);
61 } // namespace autofill
63 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_