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

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

Issue 1911823002: Convert //third_party from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update crashpad's README.chromium Created 4 years, 8 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
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 <utility> 8 #include <utility>
8 9
9 #include "base/memory/scoped_ptr.h"
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 scoped_ptr<std::string> owned_data(data); 26 std::unique_ptr<std::string> owned_data(data);
27 scoped_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);
(...skipping 11 matching lines...) Expand all
49 } 49 }
50 50
51 void ChromeStorageImpl::DoGet(const std::string& key, 51 void ChromeStorageImpl::DoGet(const std::string& key,
52 const Storage::Callback& data_ready) { 52 const Storage::Callback& data_ready) {
53 if (!backing_store_->IsInitializationComplete()) { 53 if (!backing_store_->IsInitializationComplete()) {
54 outstanding_requests_.push_back(new Request(key, data_ready)); 54 outstanding_requests_.push_back(new Request(key, data_ready));
55 return; 55 return;
56 } 56 }
57 57
58 const base::Value* value = NULL; 58 const base::Value* value = NULL;
59 scoped_ptr<std::string> data(new std::string); 59 std::unique_ptr<std::string> data(new std::string);
60 if (backing_store_->GetValue(key, &value) && value->GetAsString(data.get())) { 60 if (backing_store_->GetValue(key, &value) && value->GetAsString(data.get())) {
61 data_ready(true, key, data.release()); 61 data_ready(true, key, data.release());
62 } else if (FallbackDataStore::Get(key, data.get())) { 62 } else if (FallbackDataStore::Get(key, data.get())) {
63 data_ready(true, key, data.release()); 63 data_ready(true, key, data.release());
64 } else { 64 } else {
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

Powered by Google App Engine
This is Rietveld 408576698