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