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

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

Issue 2002012: sync: Add location info to unrecoverable error. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add error handler back to bookmark model associator Created 10 years, 6 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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_model_associator.h" 5 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 AddAll(node->GetChild(i)); 148 AddAll(node->GetChild(i));
149 } 149 }
150 150
151 const BookmarkNode* BookmarkNodeIdIndex::Find(int64 id) const { 151 const BookmarkNode* BookmarkNodeIdIndex::Find(int64 id) const {
152 BookmarkIdMap::const_iterator iter = node_index_.find(id); 152 BookmarkIdMap::const_iterator iter = node_index_.find(id);
153 return iter == node_index_.end() ? NULL : iter->second; 153 return iter == node_index_.end() ? NULL : iter->second;
154 } 154 }
155 155
156 BookmarkModelAssociator::BookmarkModelAssociator( 156 BookmarkModelAssociator::BookmarkModelAssociator(
157 ProfileSyncService* sync_service, 157 ProfileSyncService* sync_service,
158 UnrecoverableErrorHandler* error_handler) 158 UnrecoverableErrorHandler* persist_ids_error_handler)
159 : sync_service_(sync_service), 159 : sync_service_(sync_service),
160 error_handler_(error_handler), 160 persist_ids_error_handler_(persist_ids_error_handler),
161 ALLOW_THIS_IN_INITIALIZER_LIST(persist_associations_(this)) { 161 ALLOW_THIS_IN_INITIALIZER_LIST(persist_associations_(this)) {
162 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 162 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
163 DCHECK(sync_service_); 163 DCHECK(sync_service_);
164 DCHECK(persist_ids_error_handler_);
164 } 165 }
165 166
166 BookmarkModelAssociator::~BookmarkModelAssociator() { 167 BookmarkModelAssociator::~BookmarkModelAssociator() {
167 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 168 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
168 } 169 }
169 170
170 bool BookmarkModelAssociator::DisassociateModels() { 171 bool BookmarkModelAssociator::DisassociateModels() {
171 id_map_.clear(); 172 id_map_.clear();
172 id_map_inverse_.clear(); 173 id_map_inverse_.clear();
173 dirty_associations_sync_ids_.clear(); 174 dirty_associations_sync_ids_.clear();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 449
449 sync_api::WriteTransaction trans( 450 sync_api::WriteTransaction trans(
450 sync_service_->backend()->GetUserShareHandle()); 451 sync_service_->backend()->GetUserShareHandle());
451 DirtyAssociationsSyncIds::iterator iter; 452 DirtyAssociationsSyncIds::iterator iter;
452 for (iter = dirty_associations_sync_ids_.begin(); 453 for (iter = dirty_associations_sync_ids_.begin();
453 iter != dirty_associations_sync_ids_.end(); 454 iter != dirty_associations_sync_ids_.end();
454 ++iter) { 455 ++iter) {
455 int64 sync_id = *iter; 456 int64 sync_id = *iter;
456 sync_api::WriteNode sync_node(&trans); 457 sync_api::WriteNode sync_node(&trans);
457 if (!sync_node.InitByIdLookup(sync_id)) { 458 if (!sync_node.InitByIdLookup(sync_id)) {
458 error_handler_->OnUnrecoverableError(); 459 persist_ids_error_handler_->OnUnrecoverableError(FROM_HERE,
460 "Could not lookup bookmark node for ID persistence.");
459 return; 461 return;
460 } 462 }
461 const BookmarkNode* node = GetChromeNodeFromSyncId(sync_id); 463 const BookmarkNode* node = GetChromeNodeFromSyncId(sync_id);
462 if (node) 464 if (node)
463 sync_node.SetExternalId(node->id()); 465 sync_node.SetExternalId(node->id());
464 else 466 else
465 NOTREACHED(); 467 NOTREACHED();
466 } 468 }
467 dirty_associations_sync_ids_.clear(); 469 dirty_associations_sync_ids_.clear();
468 } 470 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 549
548 // It's possible that the number of nodes in the bookmark model is not the 550 // It's possible that the number of nodes in the bookmark model is not the
549 // same as number of nodes in the sync model. This can happen when the sync 551 // same as number of nodes in the sync model. This can happen when the sync
550 // model doesn't get a chance to persist its changes, for example when 552 // model doesn't get a chance to persist its changes, for example when
551 // Chrome does not shut down gracefully. In such cases we can't trust the 553 // Chrome does not shut down gracefully. In such cases we can't trust the
552 // loaded associations. 554 // loaded associations.
553 return sync_node_count == id_index.count(); 555 return sync_node_count == id_index.count();
554 } 556 }
555 557
556 } // namespace browser_sync 558 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | chrome/browser/sync/glue/data_type_controller_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698