| OLD | NEW |
| 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/theme_model_associator.h" | 5 #include "chrome/browser/sync/glue/theme_model_associator.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/sync/engine/syncapi.h" | 10 #include "chrome/browser/sync/engine/syncapi.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 ThemeModelAssociator::ThemeModelAssociator( | 30 ThemeModelAssociator::ThemeModelAssociator( |
| 31 ProfileSyncService* sync_service) | 31 ProfileSyncService* sync_service) |
| 32 : sync_service_(sync_service) { | 32 : sync_service_(sync_service) { |
| 33 DCHECK(sync_service_); | 33 DCHECK(sync_service_); |
| 34 } | 34 } |
| 35 | 35 |
| 36 ThemeModelAssociator::~ThemeModelAssociator() {} | 36 ThemeModelAssociator::~ThemeModelAssociator() {} |
| 37 | 37 |
| 38 bool ThemeModelAssociator::AssociateModels() { | 38 bool ThemeModelAssociator::AssociateModels() { |
| 39 sync_api::WriteTransaction trans( | 39 sync_api::WriteTransaction trans(sync_service_->GetUserShareHandle()); |
| 40 sync_service_->backend()->GetUserShareHandle()); | |
| 41 sync_api::ReadNode root(&trans); | 40 sync_api::ReadNode root(&trans); |
| 42 if (!root.InitByTagLookup(kThemesTag)) { | 41 if (!root.InitByTagLookup(kThemesTag)) { |
| 43 LOG(ERROR) << kNoThemesFolderError; | 42 LOG(ERROR) << kNoThemesFolderError; |
| 44 return false; | 43 return false; |
| 45 } | 44 } |
| 46 | 45 |
| 47 Profile* profile = sync_service_->profile(); | 46 Profile* profile = sync_service_->profile(); |
| 48 sync_api::WriteNode node(&trans); | 47 sync_api::WriteNode node(&trans); |
| 49 // TODO(akalin): When we have timestamps, we may want to do | 48 // TODO(akalin): When we have timestamps, we may want to do |
| 50 // something more intelligent than preferring the sync data over our | 49 // something more intelligent than preferring the sync data over our |
| (...skipping 25 matching lines...) Expand all Loading... |
| 76 } | 75 } |
| 77 | 76 |
| 78 bool ThemeModelAssociator::DisassociateModels() { | 77 bool ThemeModelAssociator::DisassociateModels() { |
| 79 // We don't maintain any association state, so nothing to do. | 78 // We don't maintain any association state, so nothing to do. |
| 80 return true; | 79 return true; |
| 81 } | 80 } |
| 82 | 81 |
| 83 bool ThemeModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { | 82 bool ThemeModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { |
| 84 DCHECK(has_nodes); | 83 DCHECK(has_nodes); |
| 85 *has_nodes = false; | 84 *has_nodes = false; |
| 86 sync_api::ReadTransaction trans( | 85 sync_api::ReadTransaction trans(sync_service_->GetUserShareHandle()); |
| 87 sync_service_->backend()->GetUserShareHandle()); | |
| 88 sync_api::ReadNode root(&trans); | 86 sync_api::ReadNode root(&trans); |
| 89 if (!root.InitByTagLookup(kThemesTag)) { | 87 if (!root.InitByTagLookup(kThemesTag)) { |
| 90 LOG(ERROR) << kNoThemesFolderError; | 88 LOG(ERROR) << kNoThemesFolderError; |
| 91 return false; | 89 return false; |
| 92 } | 90 } |
| 93 // The sync model has user created nodes iff the themes folder has | 91 // The sync model has user created nodes iff the themes folder has |
| 94 // any children. | 92 // any children. |
| 95 *has_nodes = root.GetFirstChildId() != sync_api::kInvalidId; | 93 *has_nodes = root.GetFirstChildId() != sync_api::kInvalidId; |
| 96 return true; | 94 return true; |
| 97 } | 95 } |
| 98 | 96 |
| 99 } // namespace browser_sync | 97 } // namespace browser_sync |
| OLD | NEW |