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

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

Issue 5577003: Coverity: Pass parameters by reference. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
170 } 170 }
171 171
172 bool BookmarkModelAssociator::DisassociateModels() { 172 bool BookmarkModelAssociator::DisassociateModels() {
173 id_map_.clear(); 173 id_map_.clear();
174 id_map_inverse_.clear(); 174 id_map_inverse_.clear();
175 dirty_associations_sync_ids_.clear(); 175 dirty_associations_sync_ids_.clear();
176 return true; 176 return true;
177 } 177 }
178 178
179 int64 BookmarkModelAssociator::GetSyncIdFromChromeId(int64 node_id) { 179 int64 BookmarkModelAssociator::GetSyncIdFromChromeId(const int64& node_id) {
180 BookmarkIdToSyncIdMap::const_iterator iter = id_map_.find(node_id); 180 BookmarkIdToSyncIdMap::const_iterator iter = id_map_.find(node_id);
181 return iter == id_map_.end() ? sync_api::kInvalidId : iter->second; 181 return iter == id_map_.end() ? sync_api::kInvalidId : iter->second;
182 } 182 }
183 183
184 const BookmarkNode* BookmarkModelAssociator::GetChromeNodeFromSyncId( 184 const BookmarkNode* BookmarkModelAssociator::GetChromeNodeFromSyncId(
185 int64 sync_id) { 185 int64 sync_id) {
186 SyncIdToBookmarkNodeMap::const_iterator iter = id_map_inverse_.find(sync_id); 186 SyncIdToBookmarkNodeMap::const_iterator iter = id_map_inverse_.find(sync_id);
187 return iter == id_map_inverse_.end() ? NULL : iter->second; 187 return iter == id_map_inverse_.end() ? NULL : iter->second;
188 } 188 }
189 189
190 bool BookmarkModelAssociator::InitSyncNodeFromChromeId( 190 bool BookmarkModelAssociator::InitSyncNodeFromChromeId(
191 int64 node_id, 191 const int64& node_id,
192 sync_api::BaseNode* sync_node) { 192 sync_api::BaseNode* sync_node) {
193 DCHECK(sync_node); 193 DCHECK(sync_node);
194 int64 sync_id = GetSyncIdFromChromeId(node_id); 194 int64 sync_id = GetSyncIdFromChromeId(node_id);
195 if (sync_id == sync_api::kInvalidId) 195 if (sync_id == sync_api::kInvalidId)
196 return false; 196 return false;
197 if (!sync_node->InitByIdLookup(sync_id)) 197 if (!sync_node->InitByIdLookup(sync_id))
198 return false; 198 return false;
199 DCHECK(sync_node->GetId() == sync_id); 199 DCHECK(sync_node->GetId() == sync_id);
200 return true; 200 return true;
201 } 201 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 540
541 // It's possible that the number of nodes in the bookmark model is not the 541 // It's possible that the number of nodes in the bookmark model is not the
542 // same as number of nodes in the sync model. This can happen when the sync 542 // same as number of nodes in the sync model. This can happen when the sync
543 // model doesn't get a chance to persist its changes, for example when 543 // model doesn't get a chance to persist its changes, for example when
544 // Chrome does not shut down gracefully. In such cases we can't trust the 544 // Chrome does not shut down gracefully. In such cases we can't trust the
545 // loaded associations. 545 // loaded associations.
546 return sync_node_count == id_index.count(); 546 return sync_node_count == id_index.count();
547 } 547 }
548 548
549 } // namespace browser_sync 549 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | chrome/browser/sync/glue/model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698