| 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/generic_change_processor.h" | 5 #include "chrome/browser/sync/glue/generic_change_processor.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/sync/api/syncable_service.h" | 9 #include "chrome/browser/sync/api/syncable_service.h" |
| 10 #include "chrome/browser/sync/api/sync_change.h" | 10 #include "chrome/browser/sync/api/sync_change.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 *has_nodes = false; | 234 *has_nodes = false; |
| 235 sync_api::ReadTransaction trans(FROM_HERE, share_handle()); | 235 sync_api::ReadTransaction trans(FROM_HERE, share_handle()); |
| 236 sync_api::ReadNode type_root_node(&trans); | 236 sync_api::ReadNode type_root_node(&trans); |
| 237 if (!type_root_node.InitByTagLookup(syncable::ModelTypeToRootTag(type))) { | 237 if (!type_root_node.InitByTagLookup(syncable::ModelTypeToRootTag(type))) { |
| 238 LOG(ERROR) << err_str; | 238 LOG(ERROR) << err_str; |
| 239 return false; | 239 return false; |
| 240 } | 240 } |
| 241 | 241 |
| 242 // The sync model has user created nodes if the type's root node has any | 242 // The sync model has user created nodes if the type's root node has any |
| 243 // children. | 243 // children. |
| 244 *has_nodes = sync_api::kInvalidId != type_root_node.GetFirstChildId(); | 244 *has_nodes = type_root_node.HasChildren(); |
| 245 return true; | 245 return true; |
| 246 } | 246 } |
| 247 | 247 |
| 248 bool GenericChangeProcessor::CryptoReadyIfNecessary(syncable::ModelType type) { | 248 bool GenericChangeProcessor::CryptoReadyIfNecessary(syncable::ModelType type) { |
| 249 DCHECK(CalledOnValidThread()); | 249 DCHECK(CalledOnValidThread()); |
| 250 DCHECK_NE(type, syncable::UNSPECIFIED); | 250 DCHECK_NE(type, syncable::UNSPECIFIED); |
| 251 // We only access the cryptographer while holding a transaction. | 251 // We only access the cryptographer while holding a transaction. |
| 252 sync_api::ReadTransaction trans(FROM_HERE, share_handle()); | 252 sync_api::ReadTransaction trans(FROM_HERE, share_handle()); |
| 253 const syncable::ModelTypeSet& encrypted_types = | 253 const syncable::ModelTypeSet& encrypted_types = |
| 254 GetEncryptedTypes(&trans); | 254 GetEncryptedTypes(&trans); |
| 255 return encrypted_types.count(type) == 0 || | 255 return encrypted_types.count(type) == 0 || |
| 256 trans.GetCryptographer()->is_ready(); | 256 trans.GetCryptographer()->is_ready(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void GenericChangeProcessor::StartImpl(Profile* profile) { | 259 void GenericChangeProcessor::StartImpl(Profile* profile) { |
| 260 DCHECK(CalledOnValidThread()); | 260 DCHECK(CalledOnValidThread()); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void GenericChangeProcessor::StopImpl() { | 263 void GenericChangeProcessor::StopImpl() { |
| 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 265 } | 265 } |
| 266 | 266 |
| 267 sync_api::UserShare* GenericChangeProcessor::share_handle() const { | 267 sync_api::UserShare* GenericChangeProcessor::share_handle() const { |
| 268 DCHECK(CalledOnValidThread()); | 268 DCHECK(CalledOnValidThread()); |
| 269 return share_handle_; | 269 return share_handle_; |
| 270 } | 270 } |
| 271 | 271 |
| 272 } // namespace browser_sync | 272 } // namespace browser_sync |
| OLD | NEW |