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

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

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 syncer::WriteNode node(&trans); 54 syncer::WriteNode node(&trans);
55 // TODO(akalin): When we have timestamps, we may want to do 55 // TODO(akalin): When we have timestamps, we may want to do
56 // something more intelligent than preferring the sync data over our 56 // something more intelligent than preferring the sync data over our
57 // local data. 57 // local data.
58 if (node.InitByClientTagLookup(syncable::THEMES, kCurrentThemeClientTag) == 58 if (node.InitByClientTagLookup(syncer::THEMES, kCurrentThemeClientTag) ==
59 syncer::BaseNode::INIT_OK) { 59 syncer::BaseNode::INIT_OK) {
60 // Update the current theme from the sync data. 60 // Update the current theme from the sync data.
61 // TODO(akalin): If the sync data does not have 61 // TODO(akalin): If the sync data does not have
62 // use_system_theme_by_default and we do, update that flag on the 62 // use_system_theme_by_default and we do, update that flag on the
63 // sync data. 63 // sync data.
64 sync_pb::ThemeSpecifics theme_specifics = node.GetThemeSpecifics(); 64 sync_pb::ThemeSpecifics theme_specifics = node.GetThemeSpecifics();
65 if (UpdateThemeSpecificsOrSetCurrentThemeIfNecessary(profile, 65 if (UpdateThemeSpecificsOrSetCurrentThemeIfNecessary(profile,
66 &theme_specifics)) 66 &theme_specifics))
67 node.SetThemeSpecifics(theme_specifics); 67 node.SetThemeSpecifics(theme_specifics);
68 } else { 68 } else {
69 // Set the sync data from the current theme. 69 // Set the sync data from the current theme.
70 syncer::WriteNode node(&trans); 70 syncer::WriteNode node(&trans);
71 syncer::WriteNode::InitUniqueByCreationResult result = 71 syncer::WriteNode::InitUniqueByCreationResult result =
72 node.InitUniqueByCreation(syncable::THEMES, root, 72 node.InitUniqueByCreation(syncer::THEMES, root,
73 kCurrentThemeClientTag); 73 kCurrentThemeClientTag);
74 if (result != syncer::WriteNode::INIT_SUCCESS) { 74 if (result != syncer::WriteNode::INIT_SUCCESS) {
75 return error_handler_->CreateAndUploadError( 75 return error_handler_->CreateAndUploadError(
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;
(...skipping 19 matching lines...) Expand all
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 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 111 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
112 const syncable::ModelTypeSet encrypted_types = 112 const syncer::ModelTypeSet encrypted_types =
113 syncer::GetEncryptedTypes(&trans); 113 syncer::GetEncryptedTypes(&trans);
114 return !encrypted_types.Has(syncable::THEMES) || 114 return !encrypted_types.Has(syncer::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_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698