OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // Current version of the file. | 34 // Current version of the file. |
35 static const int kCurrentVersion = 1; | 35 static const int kCurrentVersion = 1; |
36 | 36 |
37 BookmarkCodec::BookmarkCodec() | 37 BookmarkCodec::BookmarkCodec() |
38 : ids_reassigned_(false), | 38 : ids_reassigned_(false), |
39 ids_valid_(true), | 39 ids_valid_(true), |
40 maximum_id_(0) { | 40 maximum_id_(0) { |
41 } | 41 } |
42 | 42 |
| 43 BookmarkCodec::~BookmarkCodec() {} |
| 44 |
43 Value* BookmarkCodec::Encode(BookmarkModel* model) { | 45 Value* BookmarkCodec::Encode(BookmarkModel* model) { |
44 return Encode(model->GetBookmarkBarNode(), model->other_node()); | 46 return Encode(model->GetBookmarkBarNode(), model->other_node()); |
45 } | 47 } |
46 | 48 |
47 Value* BookmarkCodec::Encode(const BookmarkNode* bookmark_bar_node, | 49 Value* BookmarkCodec::Encode(const BookmarkNode* bookmark_bar_node, |
48 const BookmarkNode* other_folder_node) { | 50 const BookmarkNode* other_folder_node) { |
49 ids_reassigned_ = false; | 51 ids_reassigned_ = false; |
50 InitializeChecksum(); | 52 InitializeChecksum(); |
51 DictionaryValue* roots = new DictionaryValue(); | 53 DictionaryValue* roots = new DictionaryValue(); |
52 roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node)); | 54 roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node)); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 330 |
329 void BookmarkCodec::InitializeChecksum() { | 331 void BookmarkCodec::InitializeChecksum() { |
330 MD5Init(&md5_context_); | 332 MD5Init(&md5_context_); |
331 } | 333 } |
332 | 334 |
333 void BookmarkCodec::FinalizeChecksum() { | 335 void BookmarkCodec::FinalizeChecksum() { |
334 MD5Digest digest; | 336 MD5Digest digest; |
335 MD5Final(&digest, &md5_context_); | 337 MD5Final(&digest, &md5_context_); |
336 computed_checksum_ = MD5DigestToBase16(digest); | 338 computed_checksum_ = MD5DigestToBase16(digest); |
337 } | 339 } |
OLD | NEW |