| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 BookmarkCodec::BookmarkCodec() | 42 BookmarkCodec::BookmarkCodec() |
| 43 : ids_reassigned_(false), | 43 : ids_reassigned_(false), |
| 44 ids_valid_(true), | 44 ids_valid_(true), |
| 45 maximum_id_(0), | 45 maximum_id_(0), |
| 46 model_sync_transaction_version_( | 46 model_sync_transaction_version_( |
| 47 BookmarkNode::kInvalidSyncTransactionVersion) { | 47 BookmarkNode::kInvalidSyncTransactionVersion) { |
| 48 } | 48 } |
| 49 | 49 |
| 50 BookmarkCodec::~BookmarkCodec() {} | 50 BookmarkCodec::~BookmarkCodec() {} |
| 51 | 51 |
| 52 Value* BookmarkCodec::Encode(BookmarkModel* model) { | 52 base::Value* BookmarkCodec::Encode(BookmarkModel* model) { |
| 53 return Encode(model->bookmark_bar_node(), | 53 return Encode(model->bookmark_bar_node(), |
| 54 model->other_node(), | 54 model->other_node(), |
| 55 model->mobile_node(), | 55 model->mobile_node(), |
| 56 model->root_node()->GetMetaInfoMap(), | 56 model->root_node()->GetMetaInfoMap(), |
| 57 model->root_node()->sync_transaction_version()); | 57 model->root_node()->sync_transaction_version()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 Value* BookmarkCodec::Encode( | 60 base::Value* BookmarkCodec::Encode( |
| 61 const BookmarkNode* bookmark_bar_node, | 61 const BookmarkNode* bookmark_bar_node, |
| 62 const BookmarkNode* other_folder_node, | 62 const BookmarkNode* other_folder_node, |
| 63 const BookmarkNode* mobile_folder_node, | 63 const BookmarkNode* mobile_folder_node, |
| 64 const BookmarkNode::MetaInfoMap* model_meta_info_map, | 64 const BookmarkNode::MetaInfoMap* model_meta_info_map, |
| 65 int64 sync_transaction_version) { | 65 int64 sync_transaction_version) { |
| 66 ids_reassigned_ = false; | 66 ids_reassigned_ = false; |
| 67 InitializeChecksum(); | 67 InitializeChecksum(); |
| 68 DictionaryValue* roots = new DictionaryValue(); | 68 base::DictionaryValue* roots = new base::DictionaryValue(); |
| 69 roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node)); | 69 roots->Set(kRootFolderNameKey, EncodeNode(bookmark_bar_node)); |
| 70 roots->Set(kOtherBookmarkFolderNameKey, EncodeNode(other_folder_node)); | 70 roots->Set(kOtherBookmarkFolderNameKey, EncodeNode(other_folder_node)); |
| 71 roots->Set(kMobileBookmarkFolderNameKey, EncodeNode(mobile_folder_node)); | 71 roots->Set(kMobileBookmarkFolderNameKey, EncodeNode(mobile_folder_node)); |
| 72 if (model_meta_info_map) | 72 if (model_meta_info_map) |
| 73 roots->Set(kMetaInfo, EncodeMetaInfo(*model_meta_info_map)); | 73 roots->Set(kMetaInfo, EncodeMetaInfo(*model_meta_info_map)); |
| 74 if (sync_transaction_version != | 74 if (sync_transaction_version != |
| 75 BookmarkNode::kInvalidSyncTransactionVersion) { | 75 BookmarkNode::kInvalidSyncTransactionVersion) { |
| 76 roots->SetString(kSyncTransactionVersion, | 76 roots->SetString(kSyncTransactionVersion, |
| 77 base::Int64ToString(sync_transaction_version)); | 77 base::Int64ToString(sync_transaction_version)); |
| 78 } | 78 } |
| 79 DictionaryValue* main = new DictionaryValue(); | 79 base::DictionaryValue* main = new base::DictionaryValue(); |
| 80 main->SetInteger(kVersionKey, kCurrentVersion); | 80 main->SetInteger(kVersionKey, kCurrentVersion); |
| 81 FinalizeChecksum(); | 81 FinalizeChecksum(); |
| 82 // We are going to store the computed checksum. So set stored checksum to be | 82 // We are going to store the computed checksum. So set stored checksum to be |
| 83 // the same as computed checksum. | 83 // the same as computed checksum. |
| 84 stored_checksum_ = computed_checksum_; | 84 stored_checksum_ = computed_checksum_; |
| 85 main->Set(kChecksumKey, new base::StringValue(computed_checksum_)); | 85 main->Set(kChecksumKey, new base::StringValue(computed_checksum_)); |
| 86 main->Set(kRootsKey, roots); | 86 main->Set(kRootsKey, roots); |
| 87 return main; | 87 return main; |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool BookmarkCodec::Decode(BookmarkNode* bb_node, | 90 bool BookmarkCodec::Decode(BookmarkNode* bb_node, |
| 91 BookmarkNode* other_folder_node, | 91 BookmarkNode* other_folder_node, |
| 92 BookmarkNode* mobile_folder_node, | 92 BookmarkNode* mobile_folder_node, |
| 93 int64* max_id, | 93 int64* max_id, |
| 94 const Value& value) { | 94 const base::Value& value) { |
| 95 ids_.clear(); | 95 ids_.clear(); |
| 96 ids_reassigned_ = false; | 96 ids_reassigned_ = false; |
| 97 ids_valid_ = true; | 97 ids_valid_ = true; |
| 98 maximum_id_ = 0; | 98 maximum_id_ = 0; |
| 99 stored_checksum_.clear(); | 99 stored_checksum_.clear(); |
| 100 InitializeChecksum(); | 100 InitializeChecksum(); |
| 101 bool success = DecodeHelper(bb_node, other_folder_node, mobile_folder_node, | 101 bool success = DecodeHelper(bb_node, other_folder_node, mobile_folder_node, |
| 102 value); | 102 value); |
| 103 FinalizeChecksum(); | 103 FinalizeChecksum(); |
| 104 // If either the checksums differ or some IDs were missing/not unique, | 104 // If either the checksums differ or some IDs were missing/not unique, |
| 105 // reassign IDs. | 105 // reassign IDs. |
| 106 if (!ids_valid_ || computed_checksum() != stored_checksum()) | 106 if (!ids_valid_ || computed_checksum() != stored_checksum()) |
| 107 ReassignIDs(bb_node, other_folder_node, mobile_folder_node); | 107 ReassignIDs(bb_node, other_folder_node, mobile_folder_node); |
| 108 *max_id = maximum_id_ + 1; | 108 *max_id = maximum_id_ + 1; |
| 109 return success; | 109 return success; |
| 110 } | 110 } |
| 111 | 111 |
| 112 Value* BookmarkCodec::EncodeNode(const BookmarkNode* node) { | 112 base::Value* BookmarkCodec::EncodeNode(const BookmarkNode* node) { |
| 113 DictionaryValue* value = new DictionaryValue(); | 113 base::DictionaryValue* value = new base::DictionaryValue(); |
| 114 std::string id = base::Int64ToString(node->id()); | 114 std::string id = base::Int64ToString(node->id()); |
| 115 value->SetString(kIdKey, id); | 115 value->SetString(kIdKey, id); |
| 116 const base::string16& title = node->GetTitle(); | 116 const base::string16& title = node->GetTitle(); |
| 117 value->SetString(kNameKey, title); | 117 value->SetString(kNameKey, title); |
| 118 value->SetString(kDateAddedKey, | 118 value->SetString(kDateAddedKey, |
| 119 base::Int64ToString(node->date_added().ToInternalValue())); | 119 base::Int64ToString(node->date_added().ToInternalValue())); |
| 120 if (node->is_url()) { | 120 if (node->is_url()) { |
| 121 value->SetString(kTypeKey, kTypeURL); | 121 value->SetString(kTypeKey, kTypeURL); |
| 122 std::string url = node->url().possibly_invalid_spec(); | 122 std::string url = node->url().possibly_invalid_spec(); |
| 123 value->SetString(kURLKey, url); | 123 value->SetString(kURLKey, url); |
| 124 UpdateChecksumWithUrlNode(id, title, url); | 124 UpdateChecksumWithUrlNode(id, title, url); |
| 125 } else { | 125 } else { |
| 126 value->SetString(kTypeKey, kTypeFolder); | 126 value->SetString(kTypeKey, kTypeFolder); |
| 127 value->SetString(kDateModifiedKey, | 127 value->SetString(kDateModifiedKey, |
| 128 base::Int64ToString(node->date_folder_modified(). | 128 base::Int64ToString(node->date_folder_modified(). |
| 129 ToInternalValue())); | 129 ToInternalValue())); |
| 130 UpdateChecksumWithFolderNode(id, title); | 130 UpdateChecksumWithFolderNode(id, title); |
| 131 | 131 |
| 132 ListValue* child_values = new ListValue(); | 132 base::ListValue* child_values = new base::ListValue(); |
| 133 value->Set(kChildrenKey, child_values); | 133 value->Set(kChildrenKey, child_values); |
| 134 for (int i = 0; i < node->child_count(); ++i) | 134 for (int i = 0; i < node->child_count(); ++i) |
| 135 child_values->Append(EncodeNode(node->GetChild(i))); | 135 child_values->Append(EncodeNode(node->GetChild(i))); |
| 136 } | 136 } |
| 137 const BookmarkNode::MetaInfoMap* meta_info_map = node->GetMetaInfoMap(); | 137 const BookmarkNode::MetaInfoMap* meta_info_map = node->GetMetaInfoMap(); |
| 138 if (meta_info_map) | 138 if (meta_info_map) |
| 139 value->Set(kMetaInfo, EncodeMetaInfo(*meta_info_map)); | 139 value->Set(kMetaInfo, EncodeMetaInfo(*meta_info_map)); |
| 140 if (node->sync_transaction_version() != | 140 if (node->sync_transaction_version() != |
| 141 BookmarkNode::kInvalidSyncTransactionVersion) { | 141 BookmarkNode::kInvalidSyncTransactionVersion) { |
| 142 value->SetString(kSyncTransactionVersion, | 142 value->SetString(kSyncTransactionVersion, |
| 143 base::Int64ToString(node->sync_transaction_version())); | 143 base::Int64ToString(node->sync_transaction_version())); |
| 144 } | 144 } |
| 145 return value; | 145 return value; |
| 146 } | 146 } |
| 147 | 147 |
| 148 base::Value* BookmarkCodec::EncodeMetaInfo( | 148 base::Value* BookmarkCodec::EncodeMetaInfo( |
| 149 const BookmarkNode::MetaInfoMap& meta_info_map) { | 149 const BookmarkNode::MetaInfoMap& meta_info_map) { |
| 150 base::DictionaryValue* meta_info = new base::DictionaryValue; | 150 base::DictionaryValue* meta_info = new base::DictionaryValue; |
| 151 for (BookmarkNode::MetaInfoMap::const_iterator it = meta_info_map.begin(); | 151 for (BookmarkNode::MetaInfoMap::const_iterator it = meta_info_map.begin(); |
| 152 it != meta_info_map.end(); ++it) { | 152 it != meta_info_map.end(); ++it) { |
| 153 meta_info->SetStringWithoutPathExpansion(it->first, it->second); | 153 meta_info->SetStringWithoutPathExpansion(it->first, it->second); |
| 154 } | 154 } |
| 155 return meta_info; | 155 return meta_info; |
| 156 } | 156 } |
| 157 | 157 |
| 158 bool BookmarkCodec::DecodeHelper(BookmarkNode* bb_node, | 158 bool BookmarkCodec::DecodeHelper(BookmarkNode* bb_node, |
| 159 BookmarkNode* other_folder_node, | 159 BookmarkNode* other_folder_node, |
| 160 BookmarkNode* mobile_folder_node, | 160 BookmarkNode* mobile_folder_node, |
| 161 const Value& value) { | 161 const base::Value& value) { |
| 162 if (value.GetType() != Value::TYPE_DICTIONARY) | 162 if (value.GetType() != base::Value::TYPE_DICTIONARY) |
| 163 return false; // Unexpected type. | 163 return false; // Unexpected type. |
| 164 | 164 |
| 165 const DictionaryValue& d_value = static_cast<const DictionaryValue&>(value); | 165 const base::DictionaryValue& d_value = |
| 166 static_cast<const base::DictionaryValue&>(value); |
| 166 | 167 |
| 167 int version; | 168 int version; |
| 168 if (!d_value.GetInteger(kVersionKey, &version) || version != kCurrentVersion) | 169 if (!d_value.GetInteger(kVersionKey, &version) || version != kCurrentVersion) |
| 169 return false; // Unknown version. | 170 return false; // Unknown version. |
| 170 | 171 |
| 171 const Value* checksum_value; | 172 const base::Value* checksum_value; |
| 172 if (d_value.Get(kChecksumKey, &checksum_value)) { | 173 if (d_value.Get(kChecksumKey, &checksum_value)) { |
| 173 if (checksum_value->GetType() != Value::TYPE_STRING) | 174 if (checksum_value->GetType() != base::Value::TYPE_STRING) |
| 174 return false; | 175 return false; |
| 175 if (!checksum_value->GetAsString(&stored_checksum_)) | 176 if (!checksum_value->GetAsString(&stored_checksum_)) |
| 176 return false; | 177 return false; |
| 177 } | 178 } |
| 178 | 179 |
| 179 const Value* roots; | 180 const base::Value* roots; |
| 180 if (!d_value.Get(kRootsKey, &roots)) | 181 if (!d_value.Get(kRootsKey, &roots)) |
| 181 return false; // No roots. | 182 return false; // No roots. |
| 182 | 183 |
| 183 if (roots->GetType() != Value::TYPE_DICTIONARY) | 184 if (roots->GetType() != base::Value::TYPE_DICTIONARY) |
| 184 return false; // Invalid type for roots. | 185 return false; // Invalid type for roots. |
| 185 | 186 |
| 186 const DictionaryValue* roots_d_value = | 187 const base::DictionaryValue* roots_d_value = |
| 187 static_cast<const DictionaryValue*>(roots); | 188 static_cast<const base::DictionaryValue*>(roots); |
| 188 const Value* root_folder_value; | 189 const base::Value* root_folder_value; |
| 189 const Value* other_folder_value = NULL; | 190 const base::Value* other_folder_value = NULL; |
| 190 if (!roots_d_value->Get(kRootFolderNameKey, &root_folder_value) || | 191 if (!roots_d_value->Get(kRootFolderNameKey, &root_folder_value) || |
| 191 root_folder_value->GetType() != Value::TYPE_DICTIONARY || | 192 root_folder_value->GetType() != base::Value::TYPE_DICTIONARY || |
| 192 !roots_d_value->Get(kOtherBookmarkFolderNameKey, &other_folder_value) || | 193 !roots_d_value->Get(kOtherBookmarkFolderNameKey, &other_folder_value) || |
| 193 other_folder_value->GetType() != Value::TYPE_DICTIONARY) { | 194 other_folder_value->GetType() != base::Value::TYPE_DICTIONARY) { |
| 194 return false; // Invalid type for root folder and/or other | 195 return false; // Invalid type for root folder and/or other |
| 195 // folder. | 196 // folder. |
| 196 } | 197 } |
| 197 DecodeNode(*static_cast<const DictionaryValue*>(root_folder_value), NULL, | 198 DecodeNode(*static_cast<const base::DictionaryValue*>(root_folder_value), |
| 198 bb_node); | 199 NULL, bb_node); |
| 199 DecodeNode(*static_cast<const DictionaryValue*>(other_folder_value), NULL, | 200 DecodeNode(*static_cast<const base::DictionaryValue*>(other_folder_value), |
| 200 other_folder_node); | 201 NULL, other_folder_node); |
| 201 | 202 |
| 202 // Fail silently if we can't deserialize mobile bookmarks. We can't require | 203 // Fail silently if we can't deserialize mobile bookmarks. We can't require |
| 203 // them to exist in order to be backwards-compatible with older versions of | 204 // them to exist in order to be backwards-compatible with older versions of |
| 204 // chrome. | 205 // chrome. |
| 205 const Value* mobile_folder_value; | 206 const base::Value* mobile_folder_value; |
| 206 if (roots_d_value->Get(kMobileBookmarkFolderNameKey, &mobile_folder_value) && | 207 if (roots_d_value->Get(kMobileBookmarkFolderNameKey, &mobile_folder_value) && |
| 207 mobile_folder_value->GetType() == Value::TYPE_DICTIONARY) { | 208 mobile_folder_value->GetType() == base::Value::TYPE_DICTIONARY) { |
| 208 DecodeNode(*static_cast<const DictionaryValue*>(mobile_folder_value), NULL, | 209 DecodeNode(*static_cast<const base::DictionaryValue*>(mobile_folder_value), |
| 209 mobile_folder_node); | 210 NULL, mobile_folder_node); |
| 210 } else { | 211 } else { |
| 211 // If we didn't find the mobile folder, we're almost guaranteed to have a | 212 // If we didn't find the mobile folder, we're almost guaranteed to have a |
| 212 // duplicate id when we add the mobile folder. Consequently, if we don't | 213 // duplicate id when we add the mobile folder. Consequently, if we don't |
| 213 // intend to reassign ids in the future (ids_valid_ is still true), then at | 214 // intend to reassign ids in the future (ids_valid_ is still true), then at |
| 214 // least reassign the mobile bookmarks to avoid it colliding with anything | 215 // least reassign the mobile bookmarks to avoid it colliding with anything |
| 215 // else. | 216 // else. |
| 216 if (ids_valid_) | 217 if (ids_valid_) |
| 217 ReassignIDsHelper(mobile_folder_node); | 218 ReassignIDsHelper(mobile_folder_node); |
| 218 } | 219 } |
| 219 | 220 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 236 mobile_folder_node->set_type(BookmarkNode::MOBILE); | 237 mobile_folder_node->set_type(BookmarkNode::MOBILE); |
| 237 bb_node->SetTitle(l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_FOLDER_NAME)); | 238 bb_node->SetTitle(l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_FOLDER_NAME)); |
| 238 other_folder_node->SetTitle( | 239 other_folder_node->SetTitle( |
| 239 l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME)); | 240 l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME)); |
| 240 mobile_folder_node->SetTitle( | 241 mobile_folder_node->SetTitle( |
| 241 l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME)); | 242 l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME)); |
| 242 | 243 |
| 243 return true; | 244 return true; |
| 244 } | 245 } |
| 245 | 246 |
| 246 bool BookmarkCodec::DecodeChildren(const ListValue& child_value_list, | 247 bool BookmarkCodec::DecodeChildren(const base::ListValue& child_value_list, |
| 247 BookmarkNode* parent) { | 248 BookmarkNode* parent) { |
| 248 for (size_t i = 0; i < child_value_list.GetSize(); ++i) { | 249 for (size_t i = 0; i < child_value_list.GetSize(); ++i) { |
| 249 const Value* child_value; | 250 const base::Value* child_value; |
| 250 if (!child_value_list.Get(i, &child_value)) | 251 if (!child_value_list.Get(i, &child_value)) |
| 251 return false; | 252 return false; |
| 252 | 253 |
| 253 if (child_value->GetType() != Value::TYPE_DICTIONARY) | 254 if (child_value->GetType() != base::Value::TYPE_DICTIONARY) |
| 254 return false; | 255 return false; |
| 255 | 256 |
| 256 DecodeNode(*static_cast<const DictionaryValue*>(child_value), parent, NULL); | 257 DecodeNode(*static_cast<const base::DictionaryValue*>(child_value), |
| 258 parent, NULL); |
| 257 } | 259 } |
| 258 return true; | 260 return true; |
| 259 } | 261 } |
| 260 | 262 |
| 261 bool BookmarkCodec::DecodeNode(const DictionaryValue& value, | 263 bool BookmarkCodec::DecodeNode(const base::DictionaryValue& value, |
| 262 BookmarkNode* parent, | 264 BookmarkNode* parent, |
| 263 BookmarkNode* node) { | 265 BookmarkNode* node) { |
| 264 // If no |node| is specified, we'll create one and add it to the |parent|. | 266 // If no |node| is specified, we'll create one and add it to the |parent|. |
| 265 // Therefore, in that case, |parent| must be non-NULL. | 267 // Therefore, in that case, |parent| must be non-NULL. |
| 266 if (!node && !parent) { | 268 if (!node && !parent) { |
| 267 NOTREACHED(); | 269 NOTREACHED(); |
| 268 return false; | 270 return false; |
| 269 } | 271 } |
| 270 | 272 |
| 271 std::string id_string; | 273 std::string id_string; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 313 |
| 312 if (parent) | 314 if (parent) |
| 313 parent->Add(node, parent->child_count()); | 315 parent->Add(node, parent->child_count()); |
| 314 node->set_type(BookmarkNode::URL); | 316 node->set_type(BookmarkNode::URL); |
| 315 UpdateChecksumWithUrlNode(id_string, title, url_string); | 317 UpdateChecksumWithUrlNode(id_string, title, url_string); |
| 316 } else { | 318 } else { |
| 317 std::string last_modified_date; | 319 std::string last_modified_date; |
| 318 if (!value.GetString(kDateModifiedKey, &last_modified_date)) | 320 if (!value.GetString(kDateModifiedKey, &last_modified_date)) |
| 319 last_modified_date = base::Int64ToString(Time::Now().ToInternalValue()); | 321 last_modified_date = base::Int64ToString(Time::Now().ToInternalValue()); |
| 320 | 322 |
| 321 const Value* child_values; | 323 const base::Value* child_values; |
| 322 if (!value.Get(kChildrenKey, &child_values)) | 324 if (!value.Get(kChildrenKey, &child_values)) |
| 323 return false; | 325 return false; |
| 324 | 326 |
| 325 if (child_values->GetType() != Value::TYPE_LIST) | 327 if (child_values->GetType() != base::Value::TYPE_LIST) |
| 326 return false; | 328 return false; |
| 327 | 329 |
| 328 if (!node) { | 330 if (!node) { |
| 329 node = new BookmarkNode(id, GURL()); | 331 node = new BookmarkNode(id, GURL()); |
| 330 } else { | 332 } else { |
| 331 // If a new node is not created, explicitly assign ID to the existing one. | 333 // If a new node is not created, explicitly assign ID to the existing one. |
| 332 node->set_id(id); | 334 node->set_id(id); |
| 333 } | 335 } |
| 334 | 336 |
| 335 node->set_type(BookmarkNode::FOLDER); | 337 node->set_type(BookmarkNode::FOLDER); |
| 336 int64 internal_time; | 338 int64 internal_time; |
| 337 base::StringToInt64(last_modified_date, &internal_time); | 339 base::StringToInt64(last_modified_date, &internal_time); |
| 338 node->set_date_folder_modified(Time::FromInternalValue(internal_time)); | 340 node->set_date_folder_modified(Time::FromInternalValue(internal_time)); |
| 339 | 341 |
| 340 if (parent) | 342 if (parent) |
| 341 parent->Add(node, parent->child_count()); | 343 parent->Add(node, parent->child_count()); |
| 342 | 344 |
| 343 UpdateChecksumWithFolderNode(id_string, title); | 345 UpdateChecksumWithFolderNode(id_string, title); |
| 344 | 346 |
| 345 if (!DecodeChildren(*static_cast<const ListValue*>(child_values), node)) | 347 if (!DecodeChildren(*static_cast<const base::ListValue*>(child_values), |
| 348 node)) { |
| 346 return false; | 349 return false; |
| 350 } |
| 347 } | 351 } |
| 348 | 352 |
| 349 node->SetTitle(title); | 353 node->SetTitle(title); |
| 350 node->set_date_added(base::Time::FromInternalValue(internal_time)); | 354 node->set_date_added(base::Time::FromInternalValue(internal_time)); |
| 351 | 355 |
| 352 int64 sync_transaction_version = node->sync_transaction_version(); | 356 int64 sync_transaction_version = node->sync_transaction_version(); |
| 353 BookmarkNode::MetaInfoMap meta_info_map; | 357 BookmarkNode::MetaInfoMap meta_info_map; |
| 354 if (!DecodeMetaInfo(value, &meta_info_map, &sync_transaction_version)) | 358 if (!DecodeMetaInfo(value, &meta_info_map, &sync_transaction_version)) |
| 355 return false; | 359 return false; |
| 356 node->SetMetaInfoMap(meta_info_map); | 360 node->SetMetaInfoMap(meta_info_map); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 480 |
| 477 void BookmarkCodec::InitializeChecksum() { | 481 void BookmarkCodec::InitializeChecksum() { |
| 478 base::MD5Init(&md5_context_); | 482 base::MD5Init(&md5_context_); |
| 479 } | 483 } |
| 480 | 484 |
| 481 void BookmarkCodec::FinalizeChecksum() { | 485 void BookmarkCodec::FinalizeChecksum() { |
| 482 base::MD5Digest digest; | 486 base::MD5Digest digest; |
| 483 base::MD5Final(&digest, &md5_context_); | 487 base::MD5Final(&digest, &md5_context_); |
| 484 computed_checksum_ = base::MD5DigestToBase16(digest); | 488 computed_checksum_ = base::MD5DigestToBase16(digest); |
| 485 } | 489 } |
| OLD | NEW |