OLD | NEW |
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 "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 "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void BookmarkCodec::UpdateChecksum(const base::string16& str) { | 457 void BookmarkCodec::UpdateChecksum(const base::string16& str) { |
458 base::MD5Update(&md5_context_, | 458 base::MD5Update(&md5_context_, |
459 base::StringPiece( | 459 base::StringPiece( |
460 reinterpret_cast<const char*>(str.data()), | 460 reinterpret_cast<const char*>(str.data()), |
461 str.length() * sizeof(str[0]))); | 461 str.length() * sizeof(str[0]))); |
462 } | 462 } |
463 | 463 |
464 void BookmarkCodec::UpdateChecksumWithUrlNode(const std::string& id, | 464 void BookmarkCodec::UpdateChecksumWithUrlNode(const std::string& id, |
465 const base::string16& title, | 465 const base::string16& title, |
466 const std::string& url) { | 466 const std::string& url) { |
467 DCHECK(base::IsStringUTF8(url)); | 467 DCHECK(IsStringUTF8(url)); |
468 UpdateChecksum(id); | 468 UpdateChecksum(id); |
469 UpdateChecksum(title); | 469 UpdateChecksum(title); |
470 UpdateChecksum(kTypeURL); | 470 UpdateChecksum(kTypeURL); |
471 UpdateChecksum(url); | 471 UpdateChecksum(url); |
472 } | 472 } |
473 | 473 |
474 void BookmarkCodec::UpdateChecksumWithFolderNode(const std::string& id, | 474 void BookmarkCodec::UpdateChecksumWithFolderNode(const std::string& id, |
475 const base::string16& title) { | 475 const base::string16& title) { |
476 UpdateChecksum(id); | 476 UpdateChecksum(id); |
477 UpdateChecksum(title); | 477 UpdateChecksum(title); |
478 UpdateChecksum(kTypeFolder); | 478 UpdateChecksum(kTypeFolder); |
479 } | 479 } |
480 | 480 |
481 void BookmarkCodec::InitializeChecksum() { | 481 void BookmarkCodec::InitializeChecksum() { |
482 base::MD5Init(&md5_context_); | 482 base::MD5Init(&md5_context_); |
483 } | 483 } |
484 | 484 |
485 void BookmarkCodec::FinalizeChecksum() { | 485 void BookmarkCodec::FinalizeChecksum() { |
486 base::MD5Digest digest; | 486 base::MD5Digest digest; |
487 base::MD5Final(&digest, &md5_context_); | 487 base::MD5Final(&digest, &md5_context_); |
488 computed_checksum_ = base::MD5DigestToBase16(digest); | 488 computed_checksum_ = base::MD5DigestToBase16(digest); |
489 } | 489 } |
OLD | NEW |