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

Side by Side Diff: chrome/browser/bookmarks/bookmark_codec.cc

Issue 173296: Convert internal time format to Windows 1601 epoch on Linux & Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « base/time_unittest.cc ('k') | chrome/browser/history/history_backend.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/bookmarks/bookmark_codec.h" 5 #include "chrome/browser/bookmarks/bookmark_codec.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 ids_missing_ = true; 193 ids_missing_ = true;
194 194
195 maximum_id_ = std::max(maximum_id_, id); 195 maximum_id_ = std::max(maximum_id_, id);
196 196
197 std::wstring title; 197 std::wstring title;
198 value.GetString(kNameKey, &title); 198 value.GetString(kNameKey, &title);
199 199
200 std::wstring date_added_string; 200 std::wstring date_added_string;
201 if (!value.GetString(kDateAddedKey, &date_added_string)) 201 if (!value.GetString(kDateAddedKey, &date_added_string))
202 date_added_string = Int64ToWString(Time::Now().ToInternalValue()); 202 date_added_string = Int64ToWString(Time::Now().ToInternalValue());
203 base::Time date_added = base::Time::FromInternalValue(
204 StringToInt64(WideToUTF16Hack(date_added_string)));
205 #if !defined(OS_WIN)
206 // We changed the epoch for dates on Mac & Linux from 1970 to the Windows
207 // one of 1601. We assume any number we encounter from before 1970 is using
208 // the old format, so we need to add the delta to it.
209 if (date_added.ToInternalValue() <
210 base::Time::kWindowsEpochDeltaMicroseconds) {
211 date_added = base::Time::FromInternalValue(date_added.ToInternalValue() +
212 base::Time::kWindowsEpochDeltaMicroseconds);
213 }
214 #endif
203 215
204 std::wstring type_string; 216 std::wstring type_string;
205 if (!value.GetString(kTypeKey, &type_string)) 217 if (!value.GetString(kTypeKey, &type_string))
206 return false; 218 return false;
207 219
208 if (type_string != kTypeURL && type_string != kTypeFolder) 220 if (type_string != kTypeURL && type_string != kTypeFolder)
209 return false; // Unknown type. 221 return false; // Unknown type.
210 222
211 if (type_string == kTypeURL) { 223 if (type_string == kTypeURL) {
212 std::wstring url_string; 224 std::wstring url_string;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (parent) 260 if (parent)
249 parent->Add(parent->GetChildCount(), node); 261 parent->Add(parent->GetChildCount(), node);
250 262
251 UpdateChecksumWithFolderNode(id_string, title); 263 UpdateChecksumWithFolderNode(id_string, title);
252 264
253 if (!DecodeChildren(*static_cast<ListValue*>(child_values), node)) 265 if (!DecodeChildren(*static_cast<ListValue*>(child_values), node))
254 return false; 266 return false;
255 } 267 }
256 268
257 node->SetTitle(title); 269 node->SetTitle(title);
258 node->set_date_added(Time::FromInternalValue( 270 node->set_date_added(date_added);
259 StringToInt64(WideToUTF16Hack(date_added_string))));
260 return true; 271 return true;
261 } 272 }
262 273
263 void BookmarkCodec::ReassignIDs(BookmarkNode* bb_node, 274 void BookmarkCodec::ReassignIDs(BookmarkNode* bb_node,
264 BookmarkNode* other_node) { 275 BookmarkNode* other_node) {
265 maximum_id_ = 0; 276 maximum_id_ = 0;
266 ReassignIDsHelper(bb_node); 277 ReassignIDsHelper(bb_node);
267 ReassignIDsHelper(other_node); 278 ReassignIDsHelper(other_node);
268 ids_reassigned_ = true; 279 ids_reassigned_ = true;
269 } 280 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 312
302 void BookmarkCodec::InitializeChecksum() { 313 void BookmarkCodec::InitializeChecksum() {
303 MD5Init(&md5_context_); 314 MD5Init(&md5_context_);
304 } 315 }
305 316
306 void BookmarkCodec::FinalizeChecksum() { 317 void BookmarkCodec::FinalizeChecksum() {
307 MD5Digest digest; 318 MD5Digest digest;
308 MD5Final(&digest, &md5_context_); 319 MD5Final(&digest, &md5_context_);
309 computed_checksum_ = MD5DigestToBase16(digest); 320 computed_checksum_ = MD5DigestToBase16(digest);
310 } 321 }
OLDNEW
« no previous file with comments | « base/time_unittest.cc ('k') | chrome/browser/history/history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698