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

Unified Diff: chrome/browser/sync/notifier/server_notifier_thread.cc

Issue 2817037: Refactored ChromeInvalidationClient to have its own listener type. (Closed)
Patch Set: Addressed nick's comments Created 10 years, 6 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/notifier/server_notifier_thread.cc
diff --git a/chrome/browser/sync/notifier/server_notifier_thread.cc b/chrome/browser/sync/notifier/server_notifier_thread.cc
index 81ac612e753a77608f3f2d57ced26a69e91d76ee..19b2f4041a6c9ad1dd85c0c81ef658668de2d702 100644
--- a/chrome/browser/sync/notifier/server_notifier_thread.cc
+++ b/chrome/browser/sync/notifier/server_notifier_thread.cc
@@ -8,14 +8,8 @@
#include <vector>
#include "base/logging.h"
-#include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h"
#include "chrome/browser/sync/notifier/chrome_invalidation_client.h"
-#include "chrome/browser/sync/notifier/chrome_system_resources.h"
-#include "chrome/browser/sync/notifier/invalidation_util.h"
-#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/common/net/notifier/listener/notification_defines.h"
-#include "google/cacheinvalidation/invalidation-client-impl.h"
-#include "talk/xmpp/jid.h"
namespace sync_notifier {
@@ -56,52 +50,25 @@ void ServerNotifierThread::SendNotification(
<< "ServerNotifierThread is used";
}
-void ServerNotifierThread::Invalidate(
- const invalidation::Invalidation& invalidation,
- invalidation::Closure* callback) {
+void ServerNotifierThread::OnInvalidate(syncable::ModelType model_type) {
DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- CHECK(invalidation::IsCallbackRepeatable(callback));
- LOG(INFO) << "Invalidate: " << InvalidationToString(invalidation);
+ LOG(INFO) << "OnInvalidate: " << syncable::ModelTypeToString(model_type);
// TODO(akalin): Signal notification only for the invalidated types.
parent_message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(
this,
&ServerNotifierThread::SignalIncomingNotification));
- RunAndDeleteClosure(callback);
}
-void ServerNotifierThread::InvalidateAll(
- invalidation::Closure* callback) {
+void ServerNotifierThread::OnInvalidateAll() {
DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- CHECK(invalidation::IsCallbackRepeatable(callback));
- LOG(INFO) << "InvalidateAll";
+ LOG(INFO) << "OnInvalidateAll";
parent_message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(
this,
&ServerNotifierThread::SignalIncomingNotification));
- RunAndDeleteClosure(callback);
-}
-
-void ServerNotifierThread::AllRegistrationsLost(
- invalidation::Closure* callback) {
- DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- CHECK(invalidation::IsCallbackRepeatable(callback));
- LOG(INFO) << "AllRegistrationsLost; reregistering";
- RegisterTypes();
- RunAndDeleteClosure(callback);
-}
-
-void ServerNotifierThread::RegistrationLost(
- const invalidation::ObjectId& object_id,
- invalidation::Closure* callback) {
- DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- CHECK(invalidation::IsCallbackRepeatable(callback));
- LOG(INFO) << "RegistrationLost; reregistering: "
- << ObjectIdToString(object_id);
- RegisterTypes();
- RunAndDeleteClosure(callback);
}
void ServerNotifierThread::StartInvalidationListener() {
@@ -120,7 +87,7 @@ void ServerNotifierThread::StartInvalidationListener() {
void ServerNotifierThread::RegisterTypesAndSignalSubscribed() {
DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- RegisterTypes();
+ chrome_invalidation_client_->RegisterTypes();
parent_message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(
@@ -128,38 +95,6 @@ void ServerNotifierThread::RegisterTypesAndSignalSubscribed() {
&ServerNotifierThread::SignalSubscribed));
}
-void ServerNotifierThread::RegisterTypes() {
- DCHECK_EQ(MessageLoop::current(), worker_message_loop());
-
- // TODO(akalin): Make this configurable instead of listening to
- // notifications for all possible types.
- for (int i = syncable::FIRST_REAL_MODEL_TYPE;
- i < syncable::MODEL_TYPE_COUNT; ++i) {
- syncable::ModelType model_type = syncable::ModelTypeFromInt(i);
- std::string notification_type;
- if (!syncable::RealModelTypeToNotificationType(
- model_type, &notification_type)) {
- LOG(ERROR) << "Could not get notification type for model type "
- << syncable::ModelTypeToString(model_type);
- continue;
- }
- invalidation::ObjectId object_id;
- object_id.mutable_name()->set_string_value(notification_type);
- object_id.set_source(invalidation::ObjectId::CHROME_SYNC);
- chrome_invalidation_client_->Register(
- object_id,
- invalidation::NewPermanentCallback(
- this, &ServerNotifierThread::RegisterCallback));
- }
-}
-
-void ServerNotifierThread::RegisterCallback(
- const invalidation::RegistrationUpdateResult& result) {
- DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- // TODO(akalin): Do something meaningful here.
- LOG(INFO) << "Registered: " << RegistrationUpdateResultToString(result);
-}
-
void ServerNotifierThread::SignalSubscribed() {
DCHECK_EQ(MessageLoop::current(), parent_message_loop_);
if (delegate_) {
@@ -178,11 +113,6 @@ void ServerNotifierThread::SignalIncomingNotification() {
void ServerNotifierThread::StopInvalidationListener() {
DCHECK_EQ(MessageLoop::current(), worker_message_loop());
-
- if (chrome_invalidation_client_.get()) {
- // TODO(akalin): Need to do unregisters here?
- chrome_invalidation_client_->Stop();
- }
chrome_invalidation_client_.reset();
}
« no previous file with comments | « chrome/browser/sync/notifier/server_notifier_thread.h ('k') | chrome/browser/sync/tools/sync_listen_notifications.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698