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

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

Issue 10662035: [Sync] Put everything in sync/api into csync namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments Created 8 years, 5 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 23 matching lines...) Expand all
34 ThemeModelAssociator::ThemeModelAssociator( 34 ThemeModelAssociator::ThemeModelAssociator(
35 ProfileSyncService* sync_service, 35 ProfileSyncService* sync_service,
36 DataTypeErrorHandler* error_handler) 36 DataTypeErrorHandler* error_handler)
37 : sync_service_(sync_service), 37 : sync_service_(sync_service),
38 error_handler_(error_handler) { 38 error_handler_(error_handler) {
39 DCHECK(sync_service_); 39 DCHECK(sync_service_);
40 } 40 }
41 41
42 ThemeModelAssociator::~ThemeModelAssociator() {} 42 ThemeModelAssociator::~ThemeModelAssociator() {}
43 43
44 SyncError ThemeModelAssociator::AssociateModels() { 44 csync::SyncError ThemeModelAssociator::AssociateModels() {
45 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 45 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare());
46 csync::ReadNode root(&trans); 46 csync::ReadNode root(&trans);
47 if (root.InitByTagLookup(kThemesTag) != csync::BaseNode::INIT_OK) { 47 if (root.InitByTagLookup(kThemesTag) != csync::BaseNode::INIT_OK) {
48 return error_handler_->CreateAndUploadError(FROM_HERE, 48 return error_handler_->CreateAndUploadError(FROM_HERE,
49 kNoThemesFolderError, 49 kNoThemesFolderError,
50 model_type()); 50 model_type());
51 } 51 }
52 52
53 Profile* profile = sync_service_->profile(); 53 Profile* profile = sync_service_->profile();
54 csync::WriteNode node(&trans); 54 csync::WriteNode node(&trans);
(...skipping 21 matching lines...) Expand all
76 FROM_HERE, 76 FROM_HERE,
77 "Could not create current theme node.", 77 "Could not create current theme node.",
78 model_type()); 78 model_type());
79 } 79 }
80 node.SetIsFolder(false); 80 node.SetIsFolder(false);
81 node.SetTitle(UTF8ToWide(kCurrentThemeNodeTitle)); 81 node.SetTitle(UTF8ToWide(kCurrentThemeNodeTitle));
82 sync_pb::ThemeSpecifics theme_specifics; 82 sync_pb::ThemeSpecifics theme_specifics;
83 GetThemeSpecificsFromCurrentTheme(profile, &theme_specifics); 83 GetThemeSpecificsFromCurrentTheme(profile, &theme_specifics);
84 node.SetThemeSpecifics(theme_specifics); 84 node.SetThemeSpecifics(theme_specifics);
85 } 85 }
86 return SyncError(); 86 return csync::SyncError();
87 } 87 }
88 88
89 SyncError ThemeModelAssociator::DisassociateModels() { 89 csync::SyncError ThemeModelAssociator::DisassociateModels() {
90 // We don't maintain any association state, so nothing to do. 90 // We don't maintain any association state, so nothing to do.
91 return SyncError(); 91 return csync::SyncError();
92 } 92 }
93 93
94 bool ThemeModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { 94 bool ThemeModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) {
95 DCHECK(has_nodes); 95 DCHECK(has_nodes);
96 *has_nodes = false; 96 *has_nodes = false;
97 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 97 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
98 csync::ReadNode root(&trans); 98 csync::ReadNode root(&trans);
99 if (root.InitByTagLookup(kThemesTag) != csync::BaseNode::INIT_OK) { 99 if (root.InitByTagLookup(kThemesTag) != csync::BaseNode::INIT_OK) {
100 LOG(ERROR) << kNoThemesFolderError; 100 LOG(ERROR) << kNoThemesFolderError;
101 return false; 101 return false;
102 } 102 }
103 // The sync model has user created nodes iff the themes folder has 103 // The sync model has user created nodes iff the themes folder has
104 // any children. 104 // any children.
105 *has_nodes = root.HasChildren(); 105 *has_nodes = root.HasChildren();
106 return true; 106 return true;
107 } 107 }
108 108
109 bool ThemeModelAssociator::CryptoReadyIfNecessary() { 109 bool ThemeModelAssociator::CryptoReadyIfNecessary() {
110 // We only access the cryptographer while holding a transaction. 110 // We only access the cryptographer while holding a transaction.
111 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 111 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
112 const syncable::ModelTypeSet encrypted_types = 112 const syncable::ModelTypeSet encrypted_types =
113 csync::GetEncryptedTypes(&trans); 113 csync::GetEncryptedTypes(&trans);
114 return !encrypted_types.Has(syncable::THEMES) || 114 return !encrypted_types.Has(syncable::THEMES) ||
115 sync_service_->IsCryptographerReady(&trans); 115 sync_service_->IsCryptographerReady(&trans);
116 } 116 }
117 117
118 } // namespace browser_sync 118 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/theme_model_associator.h ('k') | chrome/browser/sync/glue/typed_url_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698