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

Side by Side Diff: chrome/browser/sync/glue/theme_change_processor.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_change_processor.h" 5 #include "chrome/browser/sync/glue/theme_change_processor.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 25 matching lines...) Expand all
36 void ThemeChangeProcessor::Observe( 36 void ThemeChangeProcessor::Observe(
37 int type, 37 int type,
38 const content::NotificationSource& source, 38 const content::NotificationSource& source,
39 const content::NotificationDetails& details) { 39 const content::NotificationDetails& details) {
40 DCHECK(running()); 40 DCHECK(running());
41 DCHECK(profile_); 41 DCHECK(profile_);
42 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); 42 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED);
43 43
44 syncer::WriteTransaction trans(FROM_HERE, share_handle()); 44 syncer::WriteTransaction trans(FROM_HERE, share_handle());
45 syncer::WriteNode node(&trans); 45 syncer::WriteNode node(&trans);
46 if (node.InitByClientTagLookup(syncable::THEMES, 46 if (node.InitByClientTagLookup(syncer::THEMES,
47 kCurrentThemeClientTag) != 47 kCurrentThemeClientTag) !=
48 syncer::BaseNode::INIT_OK) { 48 syncer::BaseNode::INIT_OK) {
49 std::string err = "Could not create node with client tag: "; 49 std::string err = "Could not create node with client tag: ";
50 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 50 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
51 err + kCurrentThemeClientTag); 51 err + kCurrentThemeClientTag);
52 return; 52 return;
53 } 53 }
54 54
55 sync_pb::ThemeSpecifics old_theme_specifics = node.GetThemeSpecifics(); 55 sync_pb::ThemeSpecifics old_theme_specifics = node.GetThemeSpecifics();
56 // Make sure to base new_theme_specifics on old_theme_specifics so 56 // Make sure to base new_theme_specifics on old_theme_specifics so
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 sync_pb::ThemeSpecifics theme_specifics; 98 sync_pb::ThemeSpecifics theme_specifics;
99 // If the action is a delete, simply use the default values for 99 // If the action is a delete, simply use the default values for
100 // ThemeSpecifics, which would cause the default theme to be set. 100 // ThemeSpecifics, which would cause the default theme to be set.
101 if (change.action != syncer::ChangeRecord::ACTION_DELETE) { 101 if (change.action != syncer::ChangeRecord::ACTION_DELETE) {
102 syncer::ReadNode node(trans); 102 syncer::ReadNode node(trans);
103 if (node.InitByIdLookup(change.id) != syncer::BaseNode::INIT_OK) { 103 if (node.InitByIdLookup(change.id) != syncer::BaseNode::INIT_OK) {
104 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 104 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
105 "Theme node lookup failed."); 105 "Theme node lookup failed.");
106 return; 106 return;
107 } 107 }
108 DCHECK_EQ(node.GetModelType(), syncable::THEMES); 108 DCHECK_EQ(node.GetModelType(), syncer::THEMES);
109 DCHECK(profile_); 109 DCHECK(profile_);
110 theme_specifics = node.GetThemeSpecifics(); 110 theme_specifics = node.GetThemeSpecifics();
111 } 111 }
112 ScopedStopObserving<ThemeChangeProcessor> stop_observing(this); 112 ScopedStopObserving<ThemeChangeProcessor> stop_observing(this);
113 SetCurrentThemeFromThemeSpecificsIfNecessary(theme_specifics, profile_); 113 SetCurrentThemeFromThemeSpecificsIfNecessary(theme_specifics, profile_);
114 } 114 }
115 115
116 void ThemeChangeProcessor::StartImpl(Profile* profile) { 116 void ThemeChangeProcessor::StartImpl(Profile* profile) {
117 DCHECK(profile); 117 DCHECK(profile);
118 profile_ = profile; 118 profile_ = profile;
(...skipping 14 matching lines...) Expand all
133 ThemeServiceFactory::GetForProfile(profile_))); 133 ThemeServiceFactory::GetForProfile(profile_)));
134 } 134 }
135 135
136 void ThemeChangeProcessor::StopObserving() { 136 void ThemeChangeProcessor::StopObserving() {
137 DCHECK(profile_); 137 DCHECK(profile_);
138 DVLOG(1) << "Unobserving all notifications"; 138 DVLOG(1) << "Unobserving all notifications";
139 notification_registrar_.RemoveAll(); 139 notification_registrar_.RemoveAll();
140 } 140 }
141 141
142 } // namespace browser_sync 142 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_registrar_unittest.cc ('k') | chrome/browser/sync/glue/theme_data_type_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698