| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/sync/glue/bookmark_change_processor.h" | 5 #include "chrome/browser/sync/glue/bookmark_change_processor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <stack> | 8 #include <stack> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 using syncer::ChangeRecord; | 39 using syncer::ChangeRecord; |
| 40 using syncer::ChangeRecordList; | 40 using syncer::ChangeRecordList; |
| 41 | 41 |
| 42 namespace browser_sync { | 42 namespace browser_sync { |
| 43 | 43 |
| 44 static const char kMobileBookmarksTag[] = "synced_bookmarks"; | 44 static const char kMobileBookmarksTag[] = "synced_bookmarks"; |
| 45 | 45 |
| 46 BookmarkChangeProcessor::BookmarkChangeProcessor( | 46 BookmarkChangeProcessor::BookmarkChangeProcessor( |
| 47 Profile* profile, | 47 Profile* profile, |
| 48 BookmarkModelAssociator* model_associator, | 48 BookmarkModelAssociator* model_associator, |
| 49 DataTypeErrorHandler* error_handler) | 49 sync_driver::DataTypeErrorHandler* error_handler) |
| 50 : ChangeProcessor(error_handler), | 50 : sync_driver::ChangeProcessor(error_handler), |
| 51 bookmark_model_(NULL), | 51 bookmark_model_(NULL), |
| 52 profile_(profile), | 52 profile_(profile), |
| 53 model_associator_(model_associator) { | 53 model_associator_(model_associator) { |
| 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 55 DCHECK(model_associator); | 55 DCHECK(model_associator); |
| 56 DCHECK(profile); | 56 DCHECK(profile); |
| 57 DCHECK(error_handler); | 57 DCHECK(error_handler); |
| 58 } | 58 } |
| 59 | 59 |
| 60 BookmarkChangeProcessor::~BookmarkChangeProcessor() { | 60 BookmarkChangeProcessor::~BookmarkChangeProcessor() { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 const BookmarkNode* parent, | 256 const BookmarkNode* parent, |
| 257 int index) { | 257 int index) { |
| 258 DCHECK(share_handle()); | 258 DCHECK(share_handle()); |
| 259 CreateOrUpdateSyncNode(parent->GetChild(index)); | 259 CreateOrUpdateSyncNode(parent->GetChild(index)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 // static | 262 // static |
| 263 int64 BookmarkChangeProcessor::CreateSyncNode(const BookmarkNode* parent, | 263 int64 BookmarkChangeProcessor::CreateSyncNode(const BookmarkNode* parent, |
| 264 BookmarkModel* model, int index, syncer::WriteTransaction* trans, | 264 BookmarkModel* model, int index, syncer::WriteTransaction* trans, |
| 265 BookmarkModelAssociator* associator, | 265 BookmarkModelAssociator* associator, |
| 266 DataTypeErrorHandler* error_handler) { | 266 sync_driver::DataTypeErrorHandler* error_handler) { |
| 267 const BookmarkNode* child = parent->GetChild(index); | 267 const BookmarkNode* child = parent->GetChild(index); |
| 268 DCHECK(child); | 268 DCHECK(child); |
| 269 | 269 |
| 270 // Create a WriteNode container to hold the new node. | 270 // Create a WriteNode container to hold the new node. |
| 271 syncer::WriteNode sync_child(trans); | 271 syncer::WriteNode sync_child(trans); |
| 272 | 272 |
| 273 // Actually create the node with the appropriate initial position. | 273 // Actually create the node with the appropriate initial position. |
| 274 if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) { | 274 if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) { |
| 275 error_handler->OnSingleDatatypeUnrecoverableError(FROM_HERE, | 275 error_handler->OnSingleDatatypeUnrecoverableError(FROM_HERE, |
| 276 "Sync node creation failed; recovery unlikely"); | 276 "Sync node creation failed; recovery unlikely"); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 310 } |
| 311 CreateOrUpdateSyncNode(node); | 311 CreateOrUpdateSyncNode(node); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // Static. | 314 // Static. |
| 315 int64 BookmarkChangeProcessor::UpdateSyncNode( | 315 int64 BookmarkChangeProcessor::UpdateSyncNode( |
| 316 const BookmarkNode* node, | 316 const BookmarkNode* node, |
| 317 BookmarkModel* model, | 317 BookmarkModel* model, |
| 318 syncer::WriteTransaction* trans, | 318 syncer::WriteTransaction* trans, |
| 319 BookmarkModelAssociator* associator, | 319 BookmarkModelAssociator* associator, |
| 320 DataTypeErrorHandler* error_handler) { | 320 sync_driver::DataTypeErrorHandler* error_handler) { |
| 321 // Lookup the sync node that's associated with |node|. | 321 // Lookup the sync node that's associated with |node|. |
| 322 syncer::WriteNode sync_node(trans); | 322 syncer::WriteNode sync_node(trans); |
| 323 if (!associator->InitSyncNodeFromChromeId(node->id(), &sync_node)) { | 323 if (!associator->InitSyncNodeFromChromeId(node->id(), &sync_node)) { |
| 324 error_handler->OnSingleDatatypeUnrecoverableError( | 324 error_handler->OnSingleDatatypeUnrecoverableError( |
| 325 FROM_HERE, "Could not load bookmark node on update."); | 325 FROM_HERE, "Could not load bookmark node on update."); |
| 326 return syncer::kInvalidId; | 326 return syncer::kInvalidId; |
| 327 } | 327 } |
| 328 UpdateSyncNodeProperties(node, model, &sync_node); | 328 UpdateSyncNodeProperties(node, model, &sync_node); |
| 329 DCHECK_EQ(sync_node.GetIsFolder(), node->is_folder()); | 329 DCHECK_EQ(sync_node.GetIsFolder(), node->is_folder()); |
| 330 DCHECK_EQ(associator->GetChromeNodeFromSyncId(sync_node.GetParentId()), | 330 DCHECK_EQ(associator->GetChromeNodeFromSyncId(sync_node.GetParentId()), |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 sync_pb::BookmarkSpecifics updated_specifics( | 838 sync_pb::BookmarkSpecifics updated_specifics( |
| 839 sync_node->GetBookmarkSpecifics()); | 839 sync_node->GetBookmarkSpecifics()); |
| 840 updated_specifics.set_favicon(favicon_bytes->front(), | 840 updated_specifics.set_favicon(favicon_bytes->front(), |
| 841 favicon_bytes->size()); | 841 favicon_bytes->size()); |
| 842 updated_specifics.set_icon_url(bookmark_node->icon_url().spec()); | 842 updated_specifics.set_icon_url(bookmark_node->icon_url().spec()); |
| 843 sync_node->SetBookmarkSpecifics(updated_specifics); | 843 sync_node->SetBookmarkSpecifics(updated_specifics); |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 | 846 |
| 847 } // namespace browser_sync | 847 } // namespace browser_sync |
| OLD | NEW |