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

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

Issue 8396022: [Sync] Add HasChildren() function and use it instead of GetFirstChildId() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 1 month 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) 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/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/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 DCHECK(has_nodes); 89 DCHECK(has_nodes);
90 *has_nodes = false; 90 *has_nodes = false;
91 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 91 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
92 sync_api::ReadNode root(&trans); 92 sync_api::ReadNode root(&trans);
93 if (!root.InitByTagLookup(kThemesTag)) { 93 if (!root.InitByTagLookup(kThemesTag)) {
94 LOG(ERROR) << kNoThemesFolderError; 94 LOG(ERROR) << kNoThemesFolderError;
95 return false; 95 return false;
96 } 96 }
97 // The sync model has user created nodes iff the themes folder has 97 // The sync model has user created nodes iff the themes folder has
98 // any children. 98 // any children.
99 *has_nodes = root.GetFirstChildId() != sync_api::kInvalidId; 99 *has_nodes = root.HasChildren();
100 return true; 100 return true;
101 } 101 }
102 102
103 bool ThemeModelAssociator::CryptoReadyIfNecessary() { 103 bool ThemeModelAssociator::CryptoReadyIfNecessary() {
104 // We only access the cryptographer while holding a transaction. 104 // We only access the cryptographer while holding a transaction.
105 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 105 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
106 syncable::ModelTypeSet encrypted_types; 106 syncable::ModelTypeSet encrypted_types;
107 encrypted_types = sync_api::GetEncryptedTypes(&trans); 107 encrypted_types = sync_api::GetEncryptedTypes(&trans);
108 return encrypted_types.count(syncable::THEMES) == 0 || 108 return encrypted_types.count(syncable::THEMES) == 0 ||
109 sync_service_->IsCryptographerReady(&trans); 109 sync_service_->IsCryptographerReady(&trans);
110 } 110 }
111 111
112 } // namespace browser_sync 112 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator.cc ('k') | chrome/browser/sync/glue/typed_url_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698