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

Side by Side Diff: third_party/libaddressinput/chromium/cpp/src/retriever.h

Issue 144353002: [rac] Use stale libaddressinput data if download fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No else after return Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // "https://i18napis.appspot.com/ssl-aggregate-address/data/US". If the |url| 73 // "https://i18napis.appspot.com/ssl-aggregate-address/data/US". If the |url|
74 // does not start with |validation_data_url| that was passed to the 74 // does not start with |validation_data_url| that was passed to the
75 // constructor, then returns an empty string. (This can happen if the user of 75 // constructor, then returns an empty string. (This can happen if the user of
76 // the library returns a bad URL in their Downloader implementation.) 76 // the library returns a bad URL in their Downloader implementation.)
77 std::string GetKeyForUrl(const std::string& url) const; 77 std::string GetKeyForUrl(const std::string& url) const;
78 78
79 // Returns true if the |url| starts with |validation_data_url| that was passed 79 // Returns true if the |url| starts with |validation_data_url| that was passed
80 // to the constructor. 80 // to the constructor.
81 bool IsValidationDataUrl(const std::string& url) const; 81 bool IsValidationDataUrl(const std::string& url) const;
82 82
83 // Looks up the callback for |key| in |requests_|, removes it from the map 83 // Looks up the callback for |key| in |requests_|, removes it from the map and
84 // and returns it. Assumes that |key| is in fact in |requests_|. 84 // invokes it with |key|, |success|, and |data| parameters.
85 scoped_ptr<Callback> GetCallbackForKey(const std::string& key); 85 void InvokeCallbackForKey(const std::string& key,
86 bool success,
87 const std::string& data);
86 88
87 const std::string validation_data_url_; 89 const std::string validation_data_url_;
88 scoped_ptr<Downloader> downloader_; 90 scoped_ptr<Downloader> downloader_;
89 scoped_ptr<Storage> storage_; 91 scoped_ptr<Storage> storage_;
92
90 // Holds pending requests. The callback pointers are owned. 93 // Holds pending requests. The callback pointers are owned.
91 std::map<std::string, Callback*> requests_; 94 std::map<std::string, Callback*> requests_;
92 95
96 // Holds data from storage that has expired timestamps. If a download fails,
97 // then this data is used as fallback.
98 std::map<std::string, std::string> stale_data_;
99
93 DISALLOW_COPY_AND_ASSIGN(Retriever); 100 DISALLOW_COPY_AND_ASSIGN(Retriever);
94 }; 101 };
95 102
96 } // namespace addressinput 103 } // namespace addressinput
97 } // namespace i18n 104 } // namespace i18n
98 105
99 #endif // I18N_ADDRESSINPUT_RETRIEVER_H_ 106 #endif // I18N_ADDRESSINPUT_RETRIEVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698