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

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

Issue 2516363005: Inline StringValue into base::Value (Closed)
Patch Set: GetString by ref and TestStringValue Fix Created 4 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
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 #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/values.h" 10 #include "base/values.h"
11 #include "components/prefs/writeable_pref_store.h" 11 #include "components/prefs/writeable_pref_store.h"
12 #include "third_party/libaddressinput/chromium/fallback_data_store.h" 12 #include "third_party/libaddressinput/chromium/fallback_data_store.h"
13 13
14 namespace autofill { 14 namespace autofill {
15 15
16 ChromeStorageImpl::ChromeStorageImpl(WriteablePrefStore* store) 16 ChromeStorageImpl::ChromeStorageImpl(WriteablePrefStore* store)
17 : backing_store_(store), 17 : backing_store_(store),
18 scoped_observer_(this) { 18 scoped_observer_(this) {
19 scoped_observer_.Add(backing_store_); 19 scoped_observer_.Add(backing_store_);
20 } 20 }
21 21
22 ChromeStorageImpl::~ChromeStorageImpl() {} 22 ChromeStorageImpl::~ChromeStorageImpl() {}
23 23
24 void ChromeStorageImpl::Put(const std::string& key, std::string* data) { 24 void ChromeStorageImpl::Put(const std::string& key, std::string* data) {
25 DCHECK(data); 25 DCHECK(data);
26 std::unique_ptr<std::string> owned_data(data); 26 std::unique_ptr<std::string> owned_data(data);
27 std::unique_ptr<base::StringValue> string_value( 27 std::unique_ptr<base::StringValue> string_value(
28 new base::StringValue(std::string())); 28 new base::StringValue(std::string()));
29 string_value->GetString()->swap(*owned_data); 29 string_value->GetString().swap(*owned_data);
30 backing_store_->SetValue(key, std::move(string_value), 30 backing_store_->SetValue(key, std::move(string_value),
31 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 31 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
32 } 32 }
33 33
34 void ChromeStorageImpl::Get(const std::string& key, 34 void ChromeStorageImpl::Get(const std::string& key,
35 const Storage::Callback& data_ready) const { 35 const Storage::Callback& data_ready) const {
36 // |Get()| should not be const, so this is just a thunk that fixes that. 36 // |Get()| should not be const, so this is just a thunk that fixes that.
37 const_cast<ChromeStorageImpl*>(this)->DoGet(key, data_ready); 37 const_cast<ChromeStorageImpl*>(this)->DoGet(key, data_ready);
38 } 38 }
39 39
(...skipping 25 matching lines...) Expand all
65 data_ready(false, key, NULL); 65 data_ready(false, key, NULL);
66 } 66 }
67 } 67 }
68 68
69 ChromeStorageImpl::Request::Request(const std::string& key, 69 ChromeStorageImpl::Request::Request(const std::string& key,
70 const Callback& callback) 70 const Callback& callback)
71 : key(key), 71 : key(key),
72 callback(callback) {} 72 callback(callback) {}
73 73
74 } // namespace autofill 74 } // namespace autofill
OLDNEW
« chromeos/network/network_state_unittest.cc ('K') | « chromeos/network/network_state_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698