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

Side by Side 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: rouslan review 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 <list>
9 #include <string>
10
11 #include "base/prefs/pref_store.h"
12 #include "base/scoped_observer.h"
13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/stora ge.h"
14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/util/ scoped_ptr.h"
15
16 class WriteablePrefStore;
17
18 // An implementation of the Storage interface which passes through to an
19 // underlying WriteablePrefStore.
20 class ChromeStorageImpl : public i18n::addressinput::Storage,
21 public PrefStore::Observer {
22 public:
23 // |store| must outlive |this|.
24 explicit ChromeStorageImpl(WriteablePrefStore* store);
25 virtual ~ChromeStorageImpl();
26
27 // i18n::addressinput::Storage implementation.
28 virtual void Put(const std::string& key, const std::string& data) OVERRIDE;
29 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready)
30 const OVERRIDE;
31
32 // PrefStore::Observer implementation.
33 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE;
34 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE;
35
36 private:
37 struct Request {
38 Request(const std::string& key, scoped_ptr<Callback> callback);
39
40 std::string key;
41 scoped_ptr<Callback> callback;
42 };
43
44 // Non-const version of Get().
45 void DoGet(const std::string& key, scoped_ptr<Callback> data_ready);
46
47 WriteablePrefStore* backing_store_; // weak
48
49 // Get requests that haven't yet been serviced.
50 std::list<scoped_ptr<Request> > outstanding_requests_;
51
52 ScopedObserver<PrefStore, ChromeStorageImpl> scoped_observer_;
53
54 DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl);
55 };
56
57 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698