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

Side by Side Diff: net/cookies/cookie_util.cc

Issue 2090713003: Make callers of FromUTC(Local)Exploded in net/ use new time API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cookies/cookie_util.h" 5 #include "net/cookies/cookie_util.h"
6 6
7 #include <cstdio> 7 #include <cstdio>
8 #include <cstdlib> 8 #include <cstdlib>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // NOTREACHED() << "Cookie parse expiration failed: " << time_string; 193 // NOTREACHED() << "Cookie parse expiration failed: " << time_string;
194 return base::Time(); 194 return base::Time();
195 } 195 }
196 196
197 // Normalize the year to expand abbreviated years to the full year. 197 // Normalize the year to expand abbreviated years to the full year.
198 if (exploded.year >= 69 && exploded.year <= 99) 198 if (exploded.year >= 69 && exploded.year <= 99)
199 exploded.year += 1900; 199 exploded.year += 1900;
200 if (exploded.year >= 0 && exploded.year <= 68) 200 if (exploded.year >= 0 && exploded.year <= 68)
201 exploded.year += 2000; 201 exploded.year += 2000;
202 202
203 // If our values are within their correct ranges, we got our time.
204 if (exploded.day_of_month >= 1 && exploded.day_of_month <= 31 && 203 if (exploded.day_of_month >= 1 && exploded.day_of_month <= 31 &&
eroman 2016/10/20 18:05:21 Can you remove this "if" statement? FromUTCExplod
205 exploded.month >= 1 && exploded.month <= 12 && 204 exploded.month >= 1 && exploded.month <= 12 && exploded.year >= 1601 &&
206 exploded.year >= 1601 && exploded.year <= 30827 && 205 exploded.year <= 30827 && exploded.hour <= 23 && exploded.minute <= 59 &&
207 exploded.hour <= 23 && exploded.minute <= 59 && exploded.second <= 59) { 206 exploded.second <= 59) {
208 return base::Time::FromUTCExploded(exploded); 207 // Time conversion can fail. See comments in base/time.h
208 base::Time out_time;
209 if (base::Time::FromUTCExploded(exploded, &out_time))
210 return out_time;
209 } 211 }
210 212
211 // One of our values was out of expected range. For well-formed input, 213 // One of our values was out of expected range. For well-formed input,
212 // the following check would be reasonable: 214 // the following check would be reasonable:
213 // NOTREACHED() << "Cookie exploded expiration failed: " << time_string; 215 // NOTREACHED() << "Cookie exploded expiration failed: " << time_string;
214 216
215 return base::Time(); 217 return base::Time();
216 } 218 }
217 219
218 GURL CookieOriginToURL(const std::string& domain, bool is_https) { 220 GURL CookieOriginToURL(const std::string& domain, bool is_https) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 buffer.append("; "); 275 buffer.append("; ");
274 buffer.append(i->first.begin(), i->first.end()); 276 buffer.append(i->first.begin(), i->first.end());
275 buffer.push_back('='); 277 buffer.push_back('=');
276 buffer.append(i->second.begin(), i->second.end()); 278 buffer.append(i->second.begin(), i->second.end());
277 } 279 }
278 return buffer; 280 return buffer;
279 } 281 }
280 282
281 } // namespace cookie_util 283 } // namespace cookie_util
282 } // namespace net 284 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698