OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 | 332 |
333 void BookmarkCodec::ReassignIDsHelper(BookmarkNode* node) { | 333 void BookmarkCodec::ReassignIDsHelper(BookmarkNode* node) { |
334 DCHECK(node); | 334 DCHECK(node); |
335 node->set_id(++maximum_id_); | 335 node->set_id(++maximum_id_); |
336 for (int i = 0; i < node->child_count(); ++i) | 336 for (int i = 0; i < node->child_count(); ++i) |
337 ReassignIDsHelper(node->GetChild(i)); | 337 ReassignIDsHelper(node->GetChild(i)); |
338 } | 338 } |
339 | 339 |
340 void BookmarkCodec::UpdateChecksum(const std::string& str) { | 340 void BookmarkCodec::UpdateChecksum(const std::string& str) { |
341 base::MD5Update(&md5_context_, str.data(), str.length() * sizeof(char)); | 341 base::MD5Update(&md5_context_, str); |
342 } | 342 } |
343 | 343 |
344 void BookmarkCodec::UpdateChecksum(const string16& str) { | 344 void BookmarkCodec::UpdateChecksum(const string16& str) { |
345 base::MD5Update(&md5_context_, str.data(), str.length() * sizeof(char16)); | 345 base::MD5Update(&md5_context_, |
| 346 base::StringPiece( |
| 347 reinterpret_cast<const char*>(str.data()), |
| 348 str.length() * sizeof(str[0]))); |
346 } | 349 } |
347 | 350 |
348 void BookmarkCodec::UpdateChecksumWithUrlNode(const std::string& id, | 351 void BookmarkCodec::UpdateChecksumWithUrlNode(const std::string& id, |
349 const string16& title, | 352 const string16& title, |
350 const std::string& url) { | 353 const std::string& url) { |
351 DCHECK(IsStringUTF8(url)); | 354 DCHECK(IsStringUTF8(url)); |
352 UpdateChecksum(id); | 355 UpdateChecksum(id); |
353 UpdateChecksum(title); | 356 UpdateChecksum(title); |
354 UpdateChecksum(kTypeURL); | 357 UpdateChecksum(kTypeURL); |
355 UpdateChecksum(url); | 358 UpdateChecksum(url); |
356 } | 359 } |
357 | 360 |
358 void BookmarkCodec::UpdateChecksumWithFolderNode(const std::string& id, | 361 void BookmarkCodec::UpdateChecksumWithFolderNode(const std::string& id, |
359 const string16& title) { | 362 const string16& title) { |
360 UpdateChecksum(id); | 363 UpdateChecksum(id); |
361 UpdateChecksum(title); | 364 UpdateChecksum(title); |
362 UpdateChecksum(kTypeFolder); | 365 UpdateChecksum(kTypeFolder); |
363 } | 366 } |
364 | 367 |
365 void BookmarkCodec::InitializeChecksum() { | 368 void BookmarkCodec::InitializeChecksum() { |
366 base::MD5Init(&md5_context_); | 369 base::MD5Init(&md5_context_); |
367 } | 370 } |
368 | 371 |
369 void BookmarkCodec::FinalizeChecksum() { | 372 void BookmarkCodec::FinalizeChecksum() { |
370 base::MD5Digest digest; | 373 base::MD5Digest digest; |
371 base::MD5Final(&digest, &md5_context_); | 374 base::MD5Final(&digest, &md5_context_); |
372 computed_checksum_ = base::MD5DigestToBase16(digest); | 375 computed_checksum_ = base::MD5DigestToBase16(digest); |
373 } | 376 } |
OLD | NEW |