Chromium Code Reviews| Index: third_party/libaddressinput/chromium/chrome_storage_impl.h |
| diff --git a/third_party/libaddressinput/chromium/chrome_storage_impl.h b/third_party/libaddressinput/chromium/chrome_storage_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c6073cca2d78027cf9de62837feefa4599c212a7 |
| --- /dev/null |
| +++ b/third_party/libaddressinput/chromium/chrome_storage_impl.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ |
| +#define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ |
| + |
| +#include <libaddressinput/storage.h> |
| +#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.
|
| + |
| +#include <list> |
| +#include <string> |
| + |
| +#include "base/prefs/pref_store.h" |
| +#include "base/scoped_observer.h" |
| + |
| +class WriteablePrefStore; |
| + |
| +namespace i18n { |
| +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.
|
| + |
| +// An implementation of the Storage interface which passes through to an |
| +// underlying WriteablePrefStore. |
| +class ChromeStorageImpl : public Storage, |
| + public PrefStore::Observer { |
| + public: |
| + // |store| must outlive |this|. |
| + ChromeStorageImpl(WriteablePrefStore* store); |
|
please use gerrit instead
2013/12/20 02:04:40
explicit
Evan Stade
2013/12/20 03:21:56
Done.
|
| + virtual ~ChromeStorageImpl(); |
| + |
| + // i18n::addressinput::Storage implementation. |
| + virtual void Put(const std::string& key, const std::string& data) OVERRIDE; |
| + virtual void Get(const std::string& key, |
| + scoped_ptr<Storage::Callback> data_ready) const OVERRIDE; |
| + |
| + // PrefStore::Observer implementation. |
| + virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; |
| + virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; |
| + |
| + private: |
| + struct Request { |
| + Request(const std::string& key, |
| + scoped_ptr<Storage::Callback> callback); |
| + |
| + std::string key; |
| + scoped_ptr<Storage::Callback> callback; |
| + }; |
| + |
| + // Non-const version of Get(). |
| + void DoGet(const std::string& key, scoped_ptr<Storage::Callback> data_ready); |
| + |
| + WriteablePrefStore* backing_store_; // weak |
| + |
| + // Get requests that haven't yet been serviced. |
| + std::list<scoped_ptr<Request> > outstanding_requests_; |
| + |
| + ScopedObserver<WriteablePrefStore, ChromeStorageImpl> scoped_observer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl); |
| +}; |
| + |
| +} // namespace i18n |
| +} // namespace addressinput |
| + |
| +#endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ |