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

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

Issue 8341094: Changed change processors to use ScopedStopObserving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unnecessary call to StartObserving(). 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/password_change_processor.h" 5 #include "chrome/browser/sync/glue/password_change_processor.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DCHECK_EQ(sync_api::ChangeRecord::ACTION_UPDATE, it->action); 190 DCHECK_EQ(sync_api::ChangeRecord::ACTION_UPDATE, it->action);
191 updated_passwords_.push_back(password); 191 updated_passwords_.push_back(password);
192 } 192 }
193 } 193 }
194 } 194 }
195 195
196 void PasswordChangeProcessor::CommitChangesFromSyncModel() { 196 void PasswordChangeProcessor::CommitChangesFromSyncModel() {
197 DCHECK(expected_loop_ == MessageLoop::current()); 197 DCHECK(expected_loop_ == MessageLoop::current());
198 if (!running()) 198 if (!running())
199 return; 199 return;
200 StopObserving(); 200 ScopedStopObserving<PasswordChangeProcessor> stop_observing(this);
201 201
202 if (!model_associator_->WriteToPasswordStore(&new_passwords_, 202 if (!model_associator_->WriteToPasswordStore(&new_passwords_,
203 &updated_passwords_, 203 &updated_passwords_,
204 &deleted_passwords_)) { 204 &deleted_passwords_)) {
205 error_handler()->OnUnrecoverableError(FROM_HERE, "Error writing passwords"); 205 error_handler()->OnUnrecoverableError(FROM_HERE, "Error writing passwords");
206 return; 206 return;
207 } 207 }
208 208
209 deleted_passwords_.clear(); 209 deleted_passwords_.clear();
210 new_passwords_.clear(); 210 new_passwords_.clear();
211 updated_passwords_.clear(); 211 updated_passwords_.clear();
212
213 StartObserving();
214 } 212 }
215 213
216 void PasswordChangeProcessor::StartImpl(Profile* profile) { 214 void PasswordChangeProcessor::StartImpl(Profile* profile) {
217 DCHECK(expected_loop_ == MessageLoop::current()); 215 DCHECK(expected_loop_ == MessageLoop::current());
218 observing_ = true; 216 observing_ = true;
219 } 217 }
220 218
221 void PasswordChangeProcessor::StopImpl() { 219 void PasswordChangeProcessor::StopImpl() {
222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
223 observing_ = false; 221 observing_ = false;
224 } 222 }
225 223
226 224
227 void PasswordChangeProcessor::StartObserving() { 225 void PasswordChangeProcessor::StartObserving() {
228 DCHECK(expected_loop_ == MessageLoop::current()); 226 DCHECK(expected_loop_ == MessageLoop::current());
229 notification_registrar_.Add(this, 227 notification_registrar_.Add(this,
230 chrome::NOTIFICATION_LOGINS_CHANGED, 228 chrome::NOTIFICATION_LOGINS_CHANGED,
231 content::Source<PasswordStore>(password_store_)); 229 content::Source<PasswordStore>(password_store_));
232 } 230 }
233 231
234 void PasswordChangeProcessor::StopObserving() { 232 void PasswordChangeProcessor::StopObserving() {
235 DCHECK(expected_loop_ == MessageLoop::current()); 233 DCHECK(expected_loop_ == MessageLoop::current());
236 notification_registrar_.Remove( 234 notification_registrar_.Remove(
237 this, 235 this,
238 chrome::NOTIFICATION_LOGINS_CHANGED, 236 chrome::NOTIFICATION_LOGINS_CHANGED,
239 content::Source<PasswordStore>(password_store_)); 237 content::Source<PasswordStore>(password_store_));
240 } 238 }
241 239
242 } // namespace browser_sync 240 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/password_change_processor.h ('k') | chrome/browser/sync/glue/session_change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698