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

Unified Diff: chrome/browser/sync/glue/data_type_manager_impl.cc

Issue 10834351: [sync] Divorce DataTypeManager from NotificationService notifications by creating a new DataTypeMa… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/glue/data_type_manager_impl.cc
diff --git a/chrome/browser/sync/glue/data_type_manager_impl.cc b/chrome/browser/sync/glue/data_type_manager_impl.cc
index 7721c4748bb1ea918503b5d7767c5812d665ff77..e55abebab18ec5ba582a1a0ab417a3b9295b619d 100644
--- a/chrome/browser/sync/glue/data_type_manager_impl.cc
+++ b/chrome/browser/sync/glue/data_type_manager_impl.cc
@@ -18,11 +18,8 @@
#include "base/stringprintf.h"
#include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
-#include "chrome/common/chrome_notification_types.h"
+#include "chrome/browser/sync/glue/data_type_manager_observer.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
using content::BrowserThread;
@@ -92,6 +89,18 @@ void DataTypeManagerImpl::ConfigureImpl(
Restart(reason);
}
+void DataTypeManagerImpl::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void DataTypeManagerImpl::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+bool DataTypeManagerImpl::HasObserver(Observer* observer) const {
+ return observers_.HasObserver(observer);
+}
+
void DataTypeManagerImpl::Restart(syncer::ConfigureReason reason) {
DVLOG(1) << "Restarting...";
model_association_manager_.Initialize(last_requested_types_);
@@ -162,17 +171,8 @@ bool DataTypeManagerImpl::ProcessReconfigure() {
void DataTypeManagerImpl::OnDownloadRetry() {
DCHECK_EQ(state_, DOWNLOAD_PENDING);
-
- // Inform the listeners we are waiting.
- ConfigureResult result;
- result.status = DataTypeManager::RETRY;
-
- // TODO(lipalani): Add a new NOTIFICATION_SYNC_CONFIGURE_RETRY.
- // crbug.com/111676.
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
- content::Source<DataTypeManager>(this),
- content::Details<const ConfigureResult>(&result));
+ last_configure_result_ = ConfigureResult(DataTypeManager::RETRY);
tim (not reviewing) 2012/08/16 18:25:20 Was there a reason you chose to move retry to its
Raghu Simha 2012/08/17 01:56:42 I did so based on the TODO that used to sit here.
+ FOR_EACH_OBSERVER(Observer, observers_, OnConfigureRetry());
}
void DataTypeManagerImpl::DownloadReady(
@@ -299,10 +299,8 @@ void DataTypeManagerImpl::Abort(ConfigureStatus status,
}
void DataTypeManagerImpl::NotifyStart() {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_SYNC_CONFIGURE_START,
- content::Source<DataTypeManager>(this),
- content::NotificationService::NoDetails());
+ last_configure_result_ = ConfigureResult();
+ FOR_EACH_OBSERVER(Observer, observers_, OnConfigureStart());
}
void DataTypeManagerImpl::NotifyDone(const ConfigureResult& result) {
@@ -335,25 +333,26 @@ void DataTypeManagerImpl::NotifyDone(const ConfigureResult& result) {
NOTREACHED();
break;
}
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
- content::Source<DataTypeManager>(this),
- content::Details<const ConfigureResult>(&result));
+ last_configure_result_ = result;
+ FOR_EACH_OBSERVER(Observer, observers_, OnConfigureDone());
}
DataTypeManager::State DataTypeManagerImpl::state() const {
return state_;
}
+const DataTypeManager::ConfigureResult&
+DataTypeManagerImpl::last_configure_result() const {
+ return last_configure_result_;
+}
+
void DataTypeManagerImpl::SetBlockedAndNotify() {
state_ = BLOCKED;
AddToConfigureTime();
DVLOG(1) << "Accumulated spent configuring: "
<< configure_time_delta_.InSecondsF() << "s";
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED,
- content::Source<DataTypeManager>(this),
- content::NotificationService::NoDetails());
+ last_configure_result_ = ConfigureResult(DataTypeManager::CONFIGURE_BLOCKED);
+ FOR_EACH_OBSERVER(Observer, observers_, OnConfigureBlocked());
}
void DataTypeManagerImpl::AddToConfigureTime() {

Powered by Google App Engine
This is Rietveld 408576698