OLD | NEW |
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 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" | 5 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "components/prefs/writeable_pref_store.h" | 12 #include "components/prefs/writeable_pref_store.h" |
13 #include "third_party/libaddressinput/chromium/fallback_data_store.h" | 13 #include "third_party/libaddressinput/chromium/fallback_data_store.h" |
14 | 14 |
15 namespace autofill { | 15 namespace autofill { |
16 | 16 |
17 ChromeStorageImpl::ChromeStorageImpl(WriteablePrefStore* store) | 17 ChromeStorageImpl::ChromeStorageImpl(WriteablePrefStore* store) |
18 : backing_store_(store), | 18 : backing_store_(store), |
19 scoped_observer_(this) { | 19 scoped_observer_(this) { |
20 scoped_observer_.Add(backing_store_); | 20 scoped_observer_.Add(backing_store_); |
21 } | 21 } |
22 | 22 |
23 ChromeStorageImpl::~ChromeStorageImpl() {} | 23 ChromeStorageImpl::~ChromeStorageImpl() {} |
24 | 24 |
25 void ChromeStorageImpl::Put(const std::string& key, std::string* data) { | 25 void ChromeStorageImpl::Put(const std::string& key, std::string* data) { |
26 DCHECK(data); | 26 DCHECK(data); |
27 std::unique_ptr<std::string> owned_data(data); | 27 std::unique_ptr<std::string> owned_data(data); |
28 backing_store_->SetValue( | 28 backing_store_->SetValue( |
29 key, base::MakeUnique<base::StringValue>(std::move(*owned_data)), | 29 key, base::MakeUnique<base::Value>(std::move(*owned_data)), |
30 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 30 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
31 } | 31 } |
32 | 32 |
33 void ChromeStorageImpl::Get(const std::string& key, | 33 void ChromeStorageImpl::Get(const std::string& key, |
34 const Storage::Callback& data_ready) const { | 34 const Storage::Callback& data_ready) const { |
35 // |Get()| should not be const, so this is just a thunk that fixes that. | 35 // |Get()| should not be const, so this is just a thunk that fixes that. |
36 const_cast<ChromeStorageImpl*>(this)->DoGet(key, data_ready); | 36 const_cast<ChromeStorageImpl*>(this)->DoGet(key, data_ready); |
37 } | 37 } |
38 | 38 |
39 void ChromeStorageImpl::OnPrefValueChanged(const std::string& key) {} | 39 void ChromeStorageImpl::OnPrefValueChanged(const std::string& key) {} |
(...skipping 24 matching lines...) Expand all Loading... |
64 data_ready(false, key, NULL); | 64 data_ready(false, key, NULL); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 ChromeStorageImpl::Request::Request(const std::string& key, | 68 ChromeStorageImpl::Request::Request(const std::string& key, |
69 const Callback& callback) | 69 const Callback& callback) |
70 : key(key), | 70 : key(key), |
71 callback(callback) {} | 71 callback(callback) {} |
72 | 72 |
73 } // namespace autofill | 73 } // namespace autofill |
OLD | NEW |