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

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

Issue 144353002: [rac] Use stale libaddressinput data if download fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. 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
(Empty)
1 // Copyright (C) 2014 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // An object to wrap data with a checksum and a timestamp. These fields are used
16 // to verify that the data is not stale or corrupted.
17
18 #ifndef I18N_ADDRESSINPUT_WRAPPER_H_
19 #define I18N_ADDRESSINPUT_WRAPPER_H_
20
21 #include <string>
22
23 namespace i18n {
24 namespace addressinput {
25
26 // Wraps data with a checksum and a timestamp. Sample usage:
27 // std::string data = ...
28 // std::string wrapped = Wrapper::Wrap(data);
29 // Process(wrapped);
30 //
31 // std::string unwrapped = wrapped;
32 // double age_in_seconds = 0.0;
33 // if (Wrapper::Unwrap(&unwrapped, &age_in_seconds) &&
34 // IsRecent(age_in_seconds)) {
35 // Process(unwrapped);
36 // }
37 class Wrapper {
Evan Stade 2014/01/23 00:07:23 Wrapper is far too generic a name to be useful. Yo
please use gerrit instead 2014/01/23 01:03:14 Done.
38 public:
39 // Returns |data| with attached checksum and current timestamp.
40 static std::string Wrap(const std::string& data);
41
42 // Strips out the timestamp and checksum from |data|. Validates the checksum.
43 // Compares the parsed timestamp with current time and saves the difference
44 // into |age_in_seconds|.
45 //
46 // The parameters should not be NULL. Does not take ownership of its
47 // parameters.
48 //
49 // Returns |true| if |data| is correctly formatted and has the correct
50 // checksum.
51 static bool Unwrap(std::string* data, double* age_in_seconds);
52 };
53
54 } // namespace addressinput
55 } // namespace i18n
56
57 #endif // I18N_ADDRESSINPUT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698