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

Unified Diff: third_party/libaddressinput/chromium/chrome_storage_impl.h

Issue 98623005: rAc i18n: implement storage interface for libaddressinput (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: scopedvector Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/prefs/writeable_pref_store.h ('k') | third_party/libaddressinput/chromium/chrome_storage_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4bb1108e26c60f3c5062919ae2cc56ccd3e599e7
--- /dev/null
+++ b/third_party/libaddressinput/chromium/chrome_storage_impl.h
@@ -0,0 +1,58 @@
+// 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 <list>
+#include <string>
+
+#include "base/memory/scoped_vector.h"
+#include "base/prefs/pref_store.h"
+#include "base/scoped_observer.h"
+#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/storage.h"
+#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/util/scoped_ptr.h"
+
+class WriteablePrefStore;
+
+// An implementation of the Storage interface which passes through to an
+// underlying WriteablePrefStore.
+class ChromeStorageImpl : public i18n::addressinput::Storage,
+ public PrefStore::Observer {
+ public:
+ // |store| must outlive |this|.
+ explicit ChromeStorageImpl(WriteablePrefStore* store);
+ 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<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<Callback> callback);
+
+ std::string key;
+ scoped_ptr<Callback> callback;
+ };
+
+ // Non-const version of Get().
+ void DoGet(const std::string& key, scoped_ptr<Callback> data_ready);
+
+ WriteablePrefStore* backing_store_; // weak
+
+ // Get requests that haven't yet been serviced.
+ ScopedVector<Request> outstanding_requests_;
+
+ ScopedObserver<PrefStore, ChromeStorageImpl> scoped_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl);
+};
+
+#endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
« no previous file with comments | « base/prefs/writeable_pref_store.h ('k') | third_party/libaddressinput/chromium/chrome_storage_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698