OLD | NEW |
1 // Copyright (C) 2013 Google Inc. | 1 // Copyright (C) 2013 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 void Retriever::OnDownloaded(bool success, | 204 void Retriever::OnDownloaded(bool success, |
205 const std::string& url, | 205 const std::string& url, |
206 scoped_ptr<std::string> downloaded_data) { | 206 scoped_ptr<std::string> downloaded_data) { |
207 const std::string& key = GetKeyForUrl(url); | 207 const std::string& key = GetKeyForUrl(url); |
208 std::map<std::string, std::string>::iterator stale_data_it = | 208 std::map<std::string, std::string>::iterator stale_data_it = |
209 stale_data_.find(key); | 209 stale_data_.find(key); |
210 | 210 |
211 if (success) { | 211 if (success) { |
212 InvokeCallbackForKey(key, success, *downloaded_data); | 212 InvokeCallbackForKey(key, success, *downloaded_data); |
213 AppendTimestamp(downloaded_data.get()); | 213 AppendTimestamp(downloaded_data.get()); |
214 // TODO(estade): storage should take a scoped_ptr. | 214 storage_->Put(key, downloaded_data.Pass()); |
215 storage_->Put(key, *downloaded_data); | |
216 } else if (stale_data_it != stale_data_.end()) { | 215 } else if (stale_data_it != stale_data_.end()) { |
217 InvokeCallbackForKey(key, true, stale_data_it->second); | 216 InvokeCallbackForKey(key, true, stale_data_it->second); |
218 } else { | 217 } else { |
219 std::string fallback; | 218 std::string fallback; |
220 success = FallbackDataStore::Get(key, &fallback); | 219 success = FallbackDataStore::Get(key, &fallback); |
221 InvokeCallbackForKey(key, success, fallback); | 220 InvokeCallbackForKey(key, success, fallback); |
222 } | 221 } |
223 | 222 |
224 if (stale_data_it != stale_data_.end()) { | 223 if (stale_data_it != stale_data_.end()) { |
225 stale_data_.erase(stale_data_it); | 224 stale_data_.erase(stale_data_it); |
(...skipping 28 matching lines...) Expand all Loading... |
254 scoped_ptr<Callback> callback(iter->second); | 253 scoped_ptr<Callback> callback(iter->second); |
255 requests_.erase(iter); | 254 requests_.erase(iter); |
256 if (callback == NULL) { | 255 if (callback == NULL) { |
257 return; | 256 return; |
258 } | 257 } |
259 (*callback)(success, key, data); | 258 (*callback)(success, key, data); |
260 } | 259 } |
261 | 260 |
262 } // namespace addressinput | 261 } // namespace addressinput |
263 } // namespace i18n | 262 } // namespace i18n |
OLD | NEW |