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

Side by Side Diff: third_party/libaddressinput/chromium/chrome_storage_impl.h

Issue 148463003: libaddressinput - reduce number of copies in storage class by 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ 5 #ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ 6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/prefs/pref_store.h" 12 #include "base/prefs/pref_store.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/stora ge.h" 14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/stora ge.h"
15 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/util/ scoped_ptr.h" 15 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/util/ scoped_ptr.h"
16 16
17 class WriteablePrefStore; 17 class WriteablePrefStore;
18 18
19 // An implementation of the Storage interface which passes through to an 19 // An implementation of the Storage interface which passes through to an
20 // underlying WriteablePrefStore. 20 // underlying WriteablePrefStore.
21 class ChromeStorageImpl : public i18n::addressinput::Storage, 21 class ChromeStorageImpl : public i18n::addressinput::Storage,
22 public PrefStore::Observer { 22 public PrefStore::Observer {
23 public: 23 public:
24 // |store| must outlive |this|. 24 // |store| must outlive |this|.
25 explicit ChromeStorageImpl(WriteablePrefStore* store); 25 explicit ChromeStorageImpl(WriteablePrefStore* store);
26 virtual ~ChromeStorageImpl(); 26 virtual ~ChromeStorageImpl();
27 27
28 // i18n::addressinput::Storage implementation. 28 // i18n::addressinput::Storage implementation.
29 virtual void Put(const std::string& key, const std::string& data) OVERRIDE; 29 virtual void Put(const std::string& key, scoped_ptr<std::string> data)
30 OVERRIDE;
30 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready) 31 virtual void Get(const std::string& key, scoped_ptr<Callback> data_ready)
31 const OVERRIDE; 32 const OVERRIDE;
32 33
33 // PrefStore::Observer implementation. 34 // PrefStore::Observer implementation.
34 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; 35 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE;
35 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; 36 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE;
36 37
37 private: 38 private:
38 struct Request { 39 struct Request {
39 Request(const std::string& key, scoped_ptr<Callback> callback); 40 Request(const std::string& key, scoped_ptr<Callback> callback);
40 41
41 std::string key; 42 std::string key;
42 scoped_ptr<Callback> callback; 43 scoped_ptr<Callback> callback;
43 }; 44 };
44 45
45 // Non-const version of Get(). 46 // Non-const version of Get().
46 void DoGet(const std::string& key, scoped_ptr<Callback> data_ready); 47 void DoGet(const std::string& key, scoped_ptr<Callback> data_ready);
47 48
48 WriteablePrefStore* backing_store_; // weak 49 WriteablePrefStore* backing_store_; // weak
49 50
50 // Get requests that haven't yet been serviced. 51 // Get requests that haven't yet been serviced.
51 ScopedVector<Request> outstanding_requests_; 52 ScopedVector<Request> outstanding_requests_;
52 53
53 ScopedObserver<PrefStore, ChromeStorageImpl> scoped_observer_; 54 ScopedObserver<PrefStore, ChromeStorageImpl> scoped_observer_;
54 55
55 DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl); 56 DISALLOW_COPY_AND_ASSIGN(ChromeStorageImpl);
56 }; 57 };
57 58
58 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_ 59 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_STORAGE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698