| Index: third_party/libaddressinput/chromium/cpp/src/retriever.cc
|
| diff --git a/third_party/libaddressinput/chromium/cpp/src/retriever.cc b/third_party/libaddressinput/chromium/cpp/src/retriever.cc
|
| index 7dd788107efec20b5b6541b144972e9810af6689..407d1809268982b0397dd48f8f562789aa3868db 100644
|
| --- a/third_party/libaddressinput/chromium/cpp/src/retriever.cc
|
| +++ b/third_party/libaddressinput/chromium/cpp/src/retriever.cc
|
| @@ -26,6 +26,7 @@
|
| #include <string>
|
| #include <utility>
|
|
|
| +#include "fallback_data_store.h"
|
| #include "lookup_key_util.h"
|
| #include "util/stl_util.h"
|
|
|
| @@ -63,13 +64,13 @@ void Retriever::Retrieve(const std::string& key,
|
|
|
| void Retriever::OnDataRetrievedFromStorage(bool success,
|
| const std::string& key,
|
| - const std::string& data) {
|
| + const std::string& stored_data) {
|
| // TODO(rouslan): Add validation for data integrity and freshness. If a
|
| // download fails, then it's OK to use stale data.
|
| if (success) {
|
| scoped_ptr<Callback> retrieved = GetCallbackForKey(key);
|
| if (retrieved != NULL) {
|
| - (*retrieved)(success, key, data);
|
| + (*retrieved)(success, key, stored_data);
|
| }
|
| } else {
|
| downloader_->Download(lookup_key_util_.GetUrlForKey(key),
|
| @@ -79,14 +80,19 @@ void Retriever::OnDataRetrievedFromStorage(bool success,
|
|
|
| void Retriever::OnDownloaded(bool success,
|
| const std::string& url,
|
| - const std::string& data) {
|
| + const std::string& downloaded_data) {
|
| + std::string response;
|
| const std::string& key = lookup_key_util_.GetKeyForUrl(url);
|
| if (success) {
|
| - storage_->Put(key, data);
|
| + storage_->Put(key, downloaded_data);
|
| + response = downloaded_data;
|
| + } else {
|
| + success = FallbackDataStore::Get(key, &response);
|
| }
|
| +
|
| scoped_ptr<Callback> retrieved = GetCallbackForKey(key);
|
| if (retrieved != NULL) {
|
| - (*retrieved)(success, key, success ? data : std::string());
|
| + (*retrieved)(success, key, response);
|
| }
|
| }
|
|
|
|
|