| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 180 DCHECK(bookmark_model_); | 180 DCHECK(bookmark_model_); |
| 181 DCHECK(user_share_); | 181 DCHECK(user_share_); |
| 182 DCHECK(unrecoverable_error_handler_); | 182 DCHECK(unrecoverable_error_handler_); |
| 183 } | 183 } |
| 184 | 184 |
| 185 BookmarkModelAssociator::~BookmarkModelAssociator() { | 185 BookmarkModelAssociator::~BookmarkModelAssociator() { |
| 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void BookmarkModelAssociator::UpdateMobileNodeVisibility() { | 189 void BookmarkModelAssociator::UpdatePermanentNodeVisibility() { |
| 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 191 DCHECK(bookmark_model_->IsLoaded()); | 191 DCHECK(bookmark_model_->IsLoaded()); |
| 192 | 192 |
| 193 bookmark_model_->SetMobileFolderVisible( | 193 bookmark_model_->SetPermanentNodeVisible( |
| 194 BookmarkNode::MOBILE, |
| 194 id_map_.find(bookmark_model_->mobile_node()->id()) != id_map_.end()); | 195 id_map_.find(bookmark_model_->mobile_node()->id()) != id_map_.end()); |
| 195 } | 196 } |
| 196 | 197 |
| 197 bool BookmarkModelAssociator::DisassociateModels(SyncError* error) { | 198 bool BookmarkModelAssociator::DisassociateModels(SyncError* error) { |
| 198 id_map_.clear(); | 199 id_map_.clear(); |
| 199 id_map_inverse_.clear(); | 200 id_map_inverse_.clear(); |
| 200 dirty_associations_sync_ids_.clear(); | 201 dirty_associations_sync_ids_.clear(); |
| 201 return true; | 202 return true; |
| 202 } | 203 } |
| 203 | 204 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 229 int64 sync_id) { | 230 int64 sync_id) { |
| 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 231 int64 node_id = node->id(); | 232 int64 node_id = node->id(); |
| 232 DCHECK_NE(sync_id, sync_api::kInvalidId); | 233 DCHECK_NE(sync_id, sync_api::kInvalidId); |
| 233 DCHECK(id_map_.find(node_id) == id_map_.end()); | 234 DCHECK(id_map_.find(node_id) == id_map_.end()); |
| 234 DCHECK(id_map_inverse_.find(sync_id) == id_map_inverse_.end()); | 235 DCHECK(id_map_inverse_.find(sync_id) == id_map_inverse_.end()); |
| 235 id_map_[node_id] = sync_id; | 236 id_map_[node_id] = sync_id; |
| 236 id_map_inverse_[sync_id] = node; | 237 id_map_inverse_[sync_id] = node; |
| 237 dirty_associations_sync_ids_.insert(sync_id); | 238 dirty_associations_sync_ids_.insert(sync_id); |
| 238 PostPersistAssociationsTask(); | 239 PostPersistAssociationsTask(); |
| 239 UpdateMobileNodeVisibility(); | 240 UpdatePermanentNodeVisibility(); |
| 240 } | 241 } |
| 241 | 242 |
| 242 void BookmarkModelAssociator::Disassociate(int64 sync_id) { | 243 void BookmarkModelAssociator::Disassociate(int64 sync_id) { |
| 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 244 SyncIdToBookmarkNodeMap::iterator iter = id_map_inverse_.find(sync_id); | 245 SyncIdToBookmarkNodeMap::iterator iter = id_map_inverse_.find(sync_id); |
| 245 if (iter == id_map_inverse_.end()) | 246 if (iter == id_map_inverse_.end()) |
| 246 return; | 247 return; |
| 247 id_map_.erase(iter->second->id()); | 248 id_map_.erase(iter->second->id()); |
| 248 id_map_inverse_.erase(iter); | 249 id_map_inverse_.erase(iter); |
| 249 dirty_associations_sync_ids_.erase(sync_id); | 250 dirty_associations_sync_ids_.erase(sync_id); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { | 617 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { |
| 617 // We only access the cryptographer while holding a transaction. | 618 // We only access the cryptographer while holding a transaction. |
| 618 sync_api::ReadTransaction trans(FROM_HERE, user_share_); | 619 sync_api::ReadTransaction trans(FROM_HERE, user_share_); |
| 619 const syncable::ModelTypeSet& encrypted_types = | 620 const syncable::ModelTypeSet& encrypted_types = |
| 620 sync_api::GetEncryptedTypes(&trans); | 621 sync_api::GetEncryptedTypes(&trans); |
| 621 return encrypted_types.count(syncable::BOOKMARKS) == 0 || | 622 return encrypted_types.count(syncable::BOOKMARKS) == 0 || |
| 622 trans.GetCryptographer()->is_ready(); | 623 trans.GetCryptographer()->is_ready(); |
| 623 } | 624 } |
| 624 | 625 |
| 625 } // namespace browser_sync | 626 } // namespace browser_sync |
| OLD | NEW |