Commit 2a09ec21 authored by atwilson@chromium.org's avatar atwilson@chromium.org

Changed change processors to use ScopedStopObserving

BUG=84918
TEST=none


Review URL: http://codereview.chromium.org/8341094

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107989 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f7a9b61
...@@ -196,7 +196,7 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel( ...@@ -196,7 +196,7 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (!running()) if (!running())
return; return;
StopObserving(); ScopedStopObserving<AutofillChangeProcessor> stop_observing(this);
sync_api::ReadNode autofill_root(trans); sync_api::ReadNode autofill_root(trans);
if (!autofill_root.InitByTagLookup(kAutofillTag)) { if (!autofill_root.InitByTagLookup(kAutofillTag)) {
...@@ -249,15 +249,13 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel( ...@@ -249,15 +249,13 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
NOTREACHED() << "Autofill specifics has no data!"; NOTREACHED() << "Autofill specifics has no data!";
} }
} }
StartObserving();
} }
void AutofillChangeProcessor::CommitChangesFromSyncModel() { void AutofillChangeProcessor::CommitChangesFromSyncModel() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (!running()) if (!running())
return; return;
StopObserving(); ScopedStopObserving<AutofillChangeProcessor> stop_observing(this);
std::vector<AutofillEntry> new_entries; std::vector<AutofillEntry> new_entries;
for (unsigned int i = 0; i < autofill_changes_.size(); i++) { for (unsigned int i = 0; i < autofill_changes_.size(); i++) {
...@@ -300,7 +298,6 @@ void AutofillChangeProcessor::CommitChangesFromSyncModel() { ...@@ -300,7 +298,6 @@ void AutofillChangeProcessor::CommitChangesFromSyncModel() {
WebDataService::NotifyOfMultipleAutofillChanges( WebDataService::NotifyOfMultipleAutofillChanges(
profile_->GetWebDataService(Profile::EXPLICIT_ACCESS)); profile_->GetWebDataService(Profile::EXPLICIT_ACCESS));
StartObserving();
} }
void AutofillChangeProcessor::ApplySyncAutofillEntryDelete( void AutofillChangeProcessor::ApplySyncAutofillEntryDelete(
......
...@@ -70,6 +70,7 @@ class AutofillChangeProcessor : public ChangeProcessor, ...@@ -70,6 +70,7 @@ class AutofillChangeProcessor : public ChangeProcessor,
virtual void StopImpl() OVERRIDE; virtual void StopImpl() OVERRIDE;
private: private:
friend class ScopedStopObserving<AutofillChangeProcessor>;
void StartObserving(); void StartObserving();
void StopObserving(); void StopObserving();
......
...@@ -197,7 +197,7 @@ void PasswordChangeProcessor::CommitChangesFromSyncModel() { ...@@ -197,7 +197,7 @@ void PasswordChangeProcessor::CommitChangesFromSyncModel() {
DCHECK(expected_loop_ == MessageLoop::current()); DCHECK(expected_loop_ == MessageLoop::current());
if (!running()) if (!running())
return; return;
StopObserving(); ScopedStopObserving<PasswordChangeProcessor> stop_observing(this);
if (!model_associator_->WriteToPasswordStore(&new_passwords_, if (!model_associator_->WriteToPasswordStore(&new_passwords_,
&updated_passwords_, &updated_passwords_,
...@@ -209,8 +209,6 @@ void PasswordChangeProcessor::CommitChangesFromSyncModel() { ...@@ -209,8 +209,6 @@ void PasswordChangeProcessor::CommitChangesFromSyncModel() {
deleted_passwords_.clear(); deleted_passwords_.clear();
new_passwords_.clear(); new_passwords_.clear();
updated_passwords_.clear(); updated_passwords_.clear();
StartObserving();
} }
void PasswordChangeProcessor::StartImpl(Profile* profile) { void PasswordChangeProcessor::StartImpl(Profile* profile) {
......
...@@ -58,6 +58,7 @@ class PasswordChangeProcessor : public ChangeProcessor, ...@@ -58,6 +58,7 @@ class PasswordChangeProcessor : public ChangeProcessor,
virtual void StopImpl() OVERRIDE; virtual void StopImpl() OVERRIDE;
private: private:
friend class ScopedStopObserving<PasswordChangeProcessor>;
void StartObserving(); void StartObserving();
void StopObserving(); void StopObserving();
......
...@@ -214,7 +214,7 @@ void SessionChangeProcessor::ApplyChangesFromSyncModel( ...@@ -214,7 +214,7 @@ void SessionChangeProcessor::ApplyChangesFromSyncModel(
return; return;
} }
StopObserving(); ScopedStopObserving<SessionChangeProcessor> stop_observing(this);
sync_api::ReadNode root(trans); sync_api::ReadNode root(trans);
if (!root.InitByTagLookup(kSessionsTag)) { if (!root.InitByTagLookup(kSessionsTag)) {
...@@ -261,7 +261,6 @@ void SessionChangeProcessor::ApplyChangesFromSyncModel( ...@@ -261,7 +261,6 @@ void SessionChangeProcessor::ApplyChangesFromSyncModel(
// if encryption was turned on. In that case, the data is still the same, // if encryption was turned on. In that case, the data is still the same,
// so we can ignore. // so we can ignore.
LOG(WARNING) << "Dropping modification to local session."; LOG(WARNING) << "Dropping modification to local session.";
StartObserving();
return; return;
} }
const base::Time& mtime = sync_node.GetModificationTime(); const base::Time& mtime = sync_node.GetModificationTime();
...@@ -274,8 +273,6 @@ void SessionChangeProcessor::ApplyChangesFromSyncModel( ...@@ -274,8 +273,6 @@ void SessionChangeProcessor::ApplyChangesFromSyncModel(
chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
content::Source<Profile>(profile_), content::Source<Profile>(profile_),
content::NotificationService::NoDetails()); content::NotificationService::NoDetails());
StartObserving();
} }
void SessionChangeProcessor::StartImpl(Profile* profile) { void SessionChangeProcessor::StartImpl(Profile* profile) {
......
...@@ -57,6 +57,7 @@ class SessionChangeProcessor : public ChangeProcessor, ...@@ -57,6 +57,7 @@ class SessionChangeProcessor : public ChangeProcessor,
virtual void StopImpl() OVERRIDE; virtual void StopImpl() OVERRIDE;
private: private:
friend class ScopedStopObserving<SessionChangeProcessor>;
void StartObserving(); void StartObserving();
void StopObserving(); void StopObserving();
SessionModelAssociator* session_model_associator_; SessionModelAssociator* session_model_associator_;
......
...@@ -106,9 +106,8 @@ void ThemeChangeProcessor::ApplyChangesFromSyncModel( ...@@ -106,9 +106,8 @@ void ThemeChangeProcessor::ApplyChangesFromSyncModel(
DCHECK(profile_); DCHECK(profile_);
theme_specifics = node.GetThemeSpecifics(); theme_specifics = node.GetThemeSpecifics();
} }
StopObserving(); ScopedStopObserving<ThemeChangeProcessor> stop_observing(this);
SetCurrentThemeFromThemeSpecificsIfNecessary(theme_specifics, profile_); SetCurrentThemeFromThemeSpecificsIfNecessary(theme_specifics, profile_);
StartObserving();
} }
void ThemeChangeProcessor::StartImpl(Profile* profile) { void ThemeChangeProcessor::StartImpl(Profile* profile) {
......
...@@ -47,6 +47,7 @@ class ThemeChangeProcessor : public ChangeProcessor, ...@@ -47,6 +47,7 @@ class ThemeChangeProcessor : public ChangeProcessor,
virtual void StopImpl() OVERRIDE; virtual void StopImpl() OVERRIDE;
private: private:
friend class ScopedStopObserving<ThemeChangeProcessor>;
void StartObserving(); void StartObserving();
void StopObserving(); void StopObserving();
......
...@@ -307,7 +307,9 @@ void TypedUrlChangeProcessor::CommitChangesFromSyncModel() { ...@@ -307,7 +307,9 @@ void TypedUrlChangeProcessor::CommitChangesFromSyncModel() {
if (!running()) if (!running())
return; return;
StopObserving(); // Make sure we stop listening for changes while we're modifying the backend,
// so we don't try to re-apply these changes to the sync DB.
ScopedStopObserving<TypedUrlChangeProcessor> stop_observing(this);
if (!pending_deleted_urls_.empty()) if (!pending_deleted_urls_.empty())
history_backend_->DeleteURLs(pending_deleted_urls_); history_backend_->DeleteURLs(pending_deleted_urls_);
...@@ -327,8 +329,6 @@ void TypedUrlChangeProcessor::CommitChangesFromSyncModel() { ...@@ -327,8 +329,6 @@ void TypedUrlChangeProcessor::CommitChangesFromSyncModel() {
pending_new_visits_.clear(); pending_new_visits_.clear();
pending_deleted_visits_.clear(); pending_deleted_visits_.clear();
pending_deleted_urls_.clear(); pending_deleted_urls_.clear();
StartObserving();
} }
void TypedUrlChangeProcessor::StartImpl(Profile* profile) { void TypedUrlChangeProcessor::StartImpl(Profile* profile) {
......
...@@ -68,6 +68,7 @@ class TypedUrlChangeProcessor : public ChangeProcessor, ...@@ -68,6 +68,7 @@ class TypedUrlChangeProcessor : public ChangeProcessor,
virtual void StopImpl(); virtual void StopImpl();
private: private:
friend class ScopedStopObserving<TypedUrlChangeProcessor>;
void StartObserving(); void StartObserving();
void StopObserving(); void StopObserving();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment