Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: chrome/browser/sync/glue/bookmark_change_processor.cc

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } else if (!sync_node.GetEntry()->good()) { 223 } else if (!sync_node.GetEntry()->good()) {
224 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 224 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
225 "Could not InitByIdLookup on BookmarkNodeChanged, good() failed"); 225 "Could not InitByIdLookup on BookmarkNodeChanged, good() failed");
226 LOG(ERROR) << "Bad entry."; 226 LOG(ERROR) << "Bad entry.";
227 } else if (sync_node.GetEntry()->Get(syncer::syncable::IS_DEL)) { 227 } else if (sync_node.GetEntry()->Get(syncer::syncable::IS_DEL)) {
228 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 228 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
229 "Could not InitByIdLookup on BookmarkNodeChanged, is_del true"); 229 "Could not InitByIdLookup on BookmarkNodeChanged, is_del true");
230 LOG(ERROR) << "Deleted entry."; 230 LOG(ERROR) << "Deleted entry.";
231 } else { 231 } else {
232 syncer::Cryptographer* crypto = trans.GetCryptographer(); 232 syncer::Cryptographer* crypto = trans.GetCryptographer();
233 syncable::ModelTypeSet encrypted_types(crypto->GetEncryptedTypes()); 233 syncer::ModelTypeSet encrypted_types(crypto->GetEncryptedTypes());
234 const sync_pb::EntitySpecifics& specifics = 234 const sync_pb::EntitySpecifics& specifics =
235 sync_node.GetEntry()->Get(syncer::syncable::SPECIFICS); 235 sync_node.GetEntry()->Get(syncer::syncable::SPECIFICS);
236 CHECK(specifics.has_encrypted()); 236 CHECK(specifics.has_encrypted());
237 const bool can_decrypt = crypto->CanDecrypt(specifics.encrypted()); 237 const bool can_decrypt = crypto->CanDecrypt(specifics.encrypted());
238 const bool agreement = encrypted_types.Has(syncable::BOOKMARKS); 238 const bool agreement = encrypted_types.Has(syncer::BOOKMARKS);
239 if (!agreement && !can_decrypt) { 239 if (!agreement && !can_decrypt) {
240 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 240 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
241 "Could not InitByIdLookup on BookmarkNodeChanged, " 241 "Could not InitByIdLookup on BookmarkNodeChanged, "
242 " Cryptographer thinks bookmarks not encrypted, and CanDecrypt" 242 " Cryptographer thinks bookmarks not encrypted, and CanDecrypt"
243 " failed."); 243 " failed.");
244 LOG(ERROR) << "Case 1."; 244 LOG(ERROR) << "Case 1.";
245 } else if (agreement && can_decrypt) { 245 } else if (agreement && can_decrypt) {
246 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 246 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
247 "Could not InitByIdLookup on BookmarkNodeChanged, " 247 "Could not InitByIdLookup on BookmarkNodeChanged, "
248 " Cryptographer thinks bookmarks are encrypted, and CanDecrypt" 248 " Cryptographer thinks bookmarks are encrypted, and CanDecrypt"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 syncer::ReadNode sync_parent(trans); 350 syncer::ReadNode sync_parent(trans);
351 if (!associator->InitSyncNodeFromChromeId(parent->id(), &sync_parent)) { 351 if (!associator->InitSyncNodeFromChromeId(parent->id(), &sync_parent)) {
352 LOG(WARNING) << "Parent lookup failed"; 352 LOG(WARNING) << "Parent lookup failed";
353 return false; 353 return false;
354 } 354 }
355 355
356 bool success = false; 356 bool success = false;
357 if (index == 0) { 357 if (index == 0) {
358 // Insert into first position. 358 // Insert into first position.
359 success = (operation == CREATE) ? 359 success = (operation == CREATE) ?
360 dst->InitByCreation(syncable::BOOKMARKS, sync_parent, NULL) : 360 dst->InitByCreation(syncer::BOOKMARKS, sync_parent, NULL) :
361 dst->SetPosition(sync_parent, NULL); 361 dst->SetPosition(sync_parent, NULL);
362 if (success) { 362 if (success) {
363 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId()); 363 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId());
364 DCHECK_EQ(dst->GetId(), sync_parent.GetFirstChildId()); 364 DCHECK_EQ(dst->GetId(), sync_parent.GetFirstChildId());
365 DCHECK_EQ(dst->GetPredecessorId(), syncer::kInvalidId); 365 DCHECK_EQ(dst->GetPredecessorId(), syncer::kInvalidId);
366 } 366 }
367 } else { 367 } else {
368 // Find the bookmark model predecessor, and insert after it. 368 // Find the bookmark model predecessor, and insert after it.
369 const BookmarkNode* prev = parent->GetChild(index - 1); 369 const BookmarkNode* prev = parent->GetChild(index - 1);
370 syncer::ReadNode sync_prev(trans); 370 syncer::ReadNode sync_prev(trans);
371 if (!associator->InitSyncNodeFromChromeId(prev->id(), &sync_prev)) { 371 if (!associator->InitSyncNodeFromChromeId(prev->id(), &sync_prev)) {
372 LOG(WARNING) << "Predecessor lookup failed"; 372 LOG(WARNING) << "Predecessor lookup failed";
373 return false; 373 return false;
374 } 374 }
375 success = (operation == CREATE) ? 375 success = (operation == CREATE) ?
376 dst->InitByCreation(syncable::BOOKMARKS, sync_parent, &sync_prev) : 376 dst->InitByCreation(syncer::BOOKMARKS, sync_parent, &sync_prev) :
377 dst->SetPosition(sync_parent, &sync_prev); 377 dst->SetPosition(sync_parent, &sync_prev);
378 if (success) { 378 if (success) {
379 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId()); 379 DCHECK_EQ(dst->GetParentId(), sync_parent.GetId());
380 DCHECK_EQ(dst->GetPredecessorId(), sync_prev.GetId()); 380 DCHECK_EQ(dst->GetPredecessorId(), sync_prev.GetId());
381 DCHECK_EQ(dst->GetId(), sync_prev.GetSuccessorId()); 381 DCHECK_EQ(dst->GetId(), sync_prev.GetSuccessorId());
382 } 382 }
383 } 383 }
384 return success; 384 return success;
385 } 385 }
386 386
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 const BookmarkNode* bookmark_node, 650 const BookmarkNode* bookmark_node,
651 BookmarkModel* model, 651 BookmarkModel* model,
652 syncer::WriteNode* sync_node) { 652 syncer::WriteNode* sync_node) {
653 std::vector<unsigned char> favicon_bytes; 653 std::vector<unsigned char> favicon_bytes;
654 EncodeFavicon(bookmark_node, model, &favicon_bytes); 654 EncodeFavicon(bookmark_node, model, &favicon_bytes);
655 if (!favicon_bytes.empty()) 655 if (!favicon_bytes.empty())
656 sync_node->SetFaviconBytes(favicon_bytes); 656 sync_node->SetFaviconBytes(favicon_bytes);
657 } 657 }
658 658
659 } // namespace browser_sync 659 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/backend_data_type_configurer.h ('k') | chrome/browser/sync/glue/bookmark_data_type_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698