| 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 <stack> | 7 #include <stack> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 syncer::ReadNode sync_parent(trans); | 397 syncer::ReadNode sync_parent(trans); |
| 398 if (!associator->InitSyncNodeFromChromeId(parent->id(), &sync_parent)) { | 398 if (!associator->InitSyncNodeFromChromeId(parent->id(), &sync_parent)) { |
| 399 LOG(WARNING) << "Parent lookup failed"; | 399 LOG(WARNING) << "Parent lookup failed"; |
| 400 return false; | 400 return false; |
| 401 } | 401 } |
| 402 | 402 |
| 403 bool success = false; | 403 bool success = false; |
| 404 if (index == 0) { | 404 if (index == 0) { |
| 405 // Insert into first position. | 405 // Insert into first position. |
| 406 success = (operation == CREATE) ? | 406 success = (operation == CREATE) ? |
| 407 dst->InitByCreation(syncer::BOOKMARKS, sync_parent, NULL) : | 407 dst->InitBookmarkByCreation(sync_parent, NULL) : |
| 408 dst->SetPosition(sync_parent, NULL); | 408 dst->SetPosition(sync_parent, NULL); |
| 409 if (success) { | 409 if (success) { |
| 410 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId()); | 410 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId()); |
| 411 DCHECK_EQ(dst->GetId(), sync_parent.GetFirstChildId()); | 411 DCHECK_EQ(dst->GetId(), sync_parent.GetFirstChildId()); |
| 412 DCHECK_EQ(dst->GetPredecessorId(), syncer::kInvalidId); | 412 DCHECK_EQ(dst->GetPredecessorId(), syncer::kInvalidId); |
| 413 } | 413 } |
| 414 } else { | 414 } else { |
| 415 // Find the bookmark model predecessor, and insert after it. | 415 // Find the bookmark model predecessor, and insert after it. |
| 416 const BookmarkNode* prev = parent->GetChild(index - 1); | 416 const BookmarkNode* prev = parent->GetChild(index - 1); |
| 417 syncer::ReadNode sync_prev(trans); | 417 syncer::ReadNode sync_prev(trans); |
| 418 if (!associator->InitSyncNodeFromChromeId(prev->id(), &sync_prev)) { | 418 if (!associator->InitSyncNodeFromChromeId(prev->id(), &sync_prev)) { |
| 419 LOG(WARNING) << "Predecessor lookup failed"; | 419 LOG(WARNING) << "Predecessor lookup failed"; |
| 420 return false; | 420 return false; |
| 421 } | 421 } |
| 422 success = (operation == CREATE) ? | 422 success = (operation == CREATE) ? |
| 423 dst->InitByCreation(syncer::BOOKMARKS, sync_parent, &sync_prev) : | 423 dst->InitBookmarkByCreation(sync_parent, &sync_prev) : |
| 424 dst->SetPosition(sync_parent, &sync_prev); | 424 dst->SetPosition(sync_parent, &sync_prev); |
| 425 if (success) { | 425 if (success) { |
| 426 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId()); | 426 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId()); |
| 427 DCHECK_EQ(dst->GetPredecessorId(), sync_prev.GetId()); | 427 DCHECK_EQ(dst->GetPredecessorId(), sync_prev.GetId()); |
| 428 DCHECK_EQ(dst->GetId(), sync_prev.GetSuccessorId()); | 428 DCHECK_EQ(dst->GetId(), sync_prev.GetSuccessorId()); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 return success; | 431 return success; |
| 432 } | 432 } |
| 433 | 433 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 sync_pb::BookmarkSpecifics updated_specifics( | 756 sync_pb::BookmarkSpecifics updated_specifics( |
| 757 sync_node->GetBookmarkSpecifics()); | 757 sync_node->GetBookmarkSpecifics()); |
| 758 updated_specifics.set_favicon(favicon_bytes->front(), | 758 updated_specifics.set_favicon(favicon_bytes->front(), |
| 759 favicon_bytes->size()); | 759 favicon_bytes->size()); |
| 760 updated_specifics.set_icon_url(bookmark_node->icon_url().spec()); | 760 updated_specifics.set_icon_url(bookmark_node->icon_url().spec()); |
| 761 sync_node->SetBookmarkSpecifics(updated_specifics); | 761 sync_node->SetBookmarkSpecifics(updated_specifics); |
| 762 } | 762 } |
| 763 } | 763 } |
| 764 | 764 |
| 765 } // namespace browser_sync | 765 } // namespace browser_sync |
| OLD | NEW |