| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/notifier/server_notifier_thread.h" | 5 #include "chrome/browser/sync/notifier/server_notifier_thread.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 MediatorThreadImpl::Logout(); | 57 MediatorThreadImpl::Logout(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void ServerNotifierThread::SendNotification( | 60 void ServerNotifierThread::SendNotification( |
| 61 const OutgoingNotificationData& data) { | 61 const OutgoingNotificationData& data) { |
| 62 DCHECK_EQ(MessageLoop::current(), parent_message_loop_); | 62 DCHECK_EQ(MessageLoop::current(), parent_message_loop_); |
| 63 NOTREACHED() << "Shouldn't send notifications if ServerNotifierThread is " | 63 NOTREACHED() << "Shouldn't send notifications if ServerNotifierThread is " |
| 64 "used"; | 64 "used"; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ServerNotifierThread::OnInvalidate(syncable::ModelType model_type) { | 67 void ServerNotifierThread::OnInvalidate( |
| 68 syncable::ModelType model_type, |
| 69 const std::string& payload) { |
| 68 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); | 70 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); |
| 69 // TODO(akalin): This is a hack to make new sync data types work | 71 // TODO(akalin): This is a hack to make new sync data types work |
| 70 // with server-issued notifications. Remove this when it's not | 72 // with server-issued notifications. Remove this when it's not |
| 71 // needed anymore. | 73 // needed anymore. |
| 72 VLOG(1) << "OnInvalidate: " << ((model_type == syncable::UNSPECIFIED) ? | 74 VLOG(1) << "OnInvalidate: " << ((model_type == syncable::UNSPECIFIED) ? |
| 73 "UNKNOWN" : syncable::ModelTypeToString(model_type)); | 75 "UNKNOWN" : syncable::ModelTypeToString(model_type)); |
| 74 | 76 |
| 75 syncable::ModelTypeBitSet model_types; | 77 syncable::ModelTypeBitSet model_types; |
| 76 model_types[model_type] = true; | 78 model_types[model_type] = true; |
| 77 IncomingNotificationData notification_data; | 79 IncomingNotificationData notification_data; |
| 78 notification_data.service_specific_data = model_types.to_string(); | 80 notification_data.service_url = model_types.to_string(); |
| 81 notification_data.service_specific_data = payload; |
| 79 observers_->Notify(&Observer::OnIncomingNotification, notification_data); | 82 observers_->Notify(&Observer::OnIncomingNotification, notification_data); |
| 80 } | 83 } |
| 81 | 84 |
| 82 void ServerNotifierThread::OnInvalidateAll() { | 85 void ServerNotifierThread::OnInvalidateAll() { |
| 83 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); | 86 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); |
| 84 VLOG(1) << "OnInvalidateAll"; | 87 VLOG(1) << "OnInvalidateAll"; |
| 85 | 88 |
| 86 syncable::ModelTypeBitSet model_types; | 89 syncable::ModelTypeBitSet model_types; |
| 87 model_types.set(); // InvalidateAll, so set all datatypes to true. | 90 model_types.set(); // InvalidateAll, so set all datatypes to true. |
| 88 IncomingNotificationData notification_data; | 91 IncomingNotificationData notification_data; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 chrome_invalidation_client_->RegisterTypes(); | 132 chrome_invalidation_client_->RegisterTypes(); |
| 130 observers_->Notify(&Observer::OnSubscriptionStateChange, true); | 133 observers_->Notify(&Observer::OnSubscriptionStateChange, true); |
| 131 } | 134 } |
| 132 | 135 |
| 133 void ServerNotifierThread::StopInvalidationListener() { | 136 void ServerNotifierThread::StopInvalidationListener() { |
| 134 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); | 137 DCHECK_EQ(MessageLoop::current(), worker_message_loop()); |
| 135 chrome_invalidation_client_.reset(); | 138 chrome_invalidation_client_.reset(); |
| 136 } | 139 } |
| 137 | 140 |
| 138 } // namespace sync_notifier | 141 } // namespace sync_notifier |
| OLD | NEW |