Index: third_party/libaddressinput/chromium/chrome_storage_impl.cc |
diff --git a/third_party/libaddressinput/chromium/chrome_storage_impl.cc b/third_party/libaddressinput/chromium/chrome_storage_impl.cc |
index b9d6d8b29aff03c9ad1e74990b7bbe9e4f6d9dbe..6c559bb019ac13413ee6b59506c6a083c57218f6 100644 |
--- a/third_party/libaddressinput/chromium/chrome_storage_impl.cc |
+++ b/third_party/libaddressinput/chromium/chrome_storage_impl.cc |
@@ -4,8 +4,10 @@ |
#include "third_party/libaddressinput/chromium/chrome_storage_impl.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/prefs/writeable_pref_store.h" |
#include "base/values.h" |
+#include "third_party/libaddressinput/chromium/fallback_data_store.h" |
namespace autofill { |
@@ -17,55 +19,53 @@ ChromeStorageImpl::ChromeStorageImpl(WriteablePrefStore* store) |
ChromeStorageImpl::~ChromeStorageImpl() {} |
-void ChromeStorageImpl::Put(const std::string& key, |
- scoped_ptr<std::string> data) { |
+void ChromeStorageImpl::Put(const std::string& key, std::string* data) { |
+ DCHECK(data); |
+ scoped_ptr<std::string> owned_data(data); |
scoped_ptr<base::StringValue> string_value( |
new base::StringValue(std::string())); |
- string_value->GetString()->swap(*data); |
+ string_value->GetString()->swap(*owned_data); |
backing_store_->SetValue(key, string_value.release()); |
} |
-void ChromeStorageImpl::Get( |
- const std::string& key, |
- scoped_ptr<Storage::Callback> data_ready) const { |
+void ChromeStorageImpl::Get(const std::string& key, |
+ const Storage::Callback& data_ready) const { |
// |Get()| should not be const, so this is just a thunk that fixes that. |
- const_cast<ChromeStorageImpl*>(this)->DoGet(key, data_ready.Pass()); |
+ const_cast<ChromeStorageImpl*>(this)->DoGet(key, data_ready); |
} |
void ChromeStorageImpl::OnPrefValueChanged(const std::string& key) {} |
void ChromeStorageImpl::OnInitializationCompleted(bool succeeded) { |
- for (std::vector<Request*>::iterator iter = |
- outstanding_requests_.begin(); |
+ for (std::vector<Request*>::iterator iter = outstanding_requests_.begin(); |
iter != outstanding_requests_.end(); ++iter) { |
- DoGet((*iter)->key, (*iter)->callback.Pass()); |
+ DoGet((*iter)->key, (*iter)->callback); |
} |
outstanding_requests_.clear(); |
} |
-void ChromeStorageImpl::DoGet( |
- const std::string& key, |
- scoped_ptr<Storage::Callback> data_ready) { |
+void ChromeStorageImpl::DoGet(const std::string& key, |
+ const Storage::Callback& data_ready) { |
if (!backing_store_->IsInitializationComplete()) { |
- outstanding_requests_.push_back( |
- new Request(key, data_ready.Pass())); |
+ outstanding_requests_.push_back(new Request(key, data_ready)); |
return; |
} |
const base::Value* value = NULL; |
- const base::StringValue* string_value = NULL; |
- if (backing_store_->GetValue(key, &value) && |
- value->GetAsString(&string_value)) { |
- (*data_ready)(true, key, string_value->GetString()); |
+ scoped_ptr<std::string> data(new std::string); |
+ if (backing_store_->GetValue(key, &value) && value->GetAsString(data.get())) { |
+ data_ready(true, key, data.release()); |
+ } else if (FallbackDataStore::Get(key, data.get())) { |
+ data_ready(true, key, data.release()); |
} else { |
- (*data_ready)(false, key, std::string()); |
+ data_ready(false, key, NULL); |
} |
} |
ChromeStorageImpl::Request::Request(const std::string& key, |
- scoped_ptr<Storage::Callback> callback) |
+ const Callback& callback) |
: key(key), |
- callback(callback.Pass()) {} |
+ callback(callback) {} |
} // namespace autofill |