| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cstddef> | 5 #include <cstddef> |
| 6 #include <cstdio> | 6 #include <cstdio> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const char kTrySslTcpFirstSwitch[] = "try-ssltcp-first"; | 47 const char kTrySslTcpFirstSwitch[] = "try-ssltcp-first"; |
| 48 const char kAllowInsecureConnectionSwitch[] = "allow-insecure-connection"; | 48 const char kAllowInsecureConnectionSwitch[] = "allow-insecure-connection"; |
| 49 const char kNotificationMethodSwitch[] = "notification-method"; | 49 const char kNotificationMethodSwitch[] = "notification-method"; |
| 50 | 50 |
| 51 // Class to print received notifications events. | 51 // Class to print received notifications events. |
| 52 class NotificationPrinter : public InvalidationHandler { | 52 class NotificationPrinter : public InvalidationHandler { |
| 53 public: | 53 public: |
| 54 NotificationPrinter() {} | 54 NotificationPrinter() {} |
| 55 virtual ~NotificationPrinter() {} | 55 virtual ~NotificationPrinter() {} |
| 56 | 56 |
| 57 virtual void OnNotificationsEnabled() OVERRIDE { | 57 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE { |
| 58 LOG(INFO) << "Notifications enabled"; | 58 LOG(INFO) << "Invalidator state changed to " |
| 59 << InvalidatorStateToString(state); |
| 59 } | 60 } |
| 60 | 61 |
| 61 virtual void OnNotificationsDisabled( | 62 virtual void OnIncomingInvalidation( |
| 62 NotificationsDisabledReason reason) OVERRIDE { | |
| 63 LOG(INFO) << "Notifications disabled with reason " | |
| 64 << NotificationsDisabledReasonToString(reason); | |
| 65 } | |
| 66 | |
| 67 virtual void OnIncomingNotification( | |
| 68 const ObjectIdStateMap& id_state_map, | 63 const ObjectIdStateMap& id_state_map, |
| 69 IncomingNotificationSource source) OVERRIDE { | 64 IncomingInvalidationSource source) OVERRIDE { |
| 70 const ModelTypeStateMap& type_state_map = | 65 const ModelTypeStateMap& type_state_map = |
| 71 ObjectIdStateMapToModelTypeStateMap(id_state_map); | 66 ObjectIdStateMapToModelTypeStateMap(id_state_map); |
| 72 for (ModelTypeStateMap::const_iterator it = type_state_map.begin(); | 67 for (ModelTypeStateMap::const_iterator it = type_state_map.begin(); |
| 73 it != type_state_map.end(); ++it) { | 68 it != type_state_map.end(); ++it) { |
| 74 LOG(INFO) << (source == REMOTE_NOTIFICATION ? "Remote" : "Local") | 69 LOG(INFO) << (source == REMOTE_INVALIDATION ? "Remote" : "Local") |
| 75 << " Notification: type = " | 70 << " Invalidation: type = " |
| 76 << ModelTypeToString(it->first) | 71 << ModelTypeToString(it->first) |
| 77 << ", payload = " << it->second.payload; | 72 << ", payload = " << it->second.payload; |
| 78 } | 73 } |
| 79 } | 74 } |
| 80 | 75 |
| 81 private: | 76 private: |
| 82 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter); | 77 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter); |
| 83 }; | 78 }; |
| 84 | 79 |
| 85 class NullInvalidationStateTracker | 80 class NullInvalidationStateTracker |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 io_thread.Stop(); | 256 io_thread.Stop(); |
| 262 return 0; | 257 return 0; |
| 263 } | 258 } |
| 264 | 259 |
| 265 } // namespace | 260 } // namespace |
| 266 } // namespace syncer | 261 } // namespace syncer |
| 267 | 262 |
| 268 int main(int argc, char* argv[]) { | 263 int main(int argc, char* argv[]) { |
| 269 return syncer::SyncListenNotificationsMain(argc, argv); | 264 return syncer::SyncListenNotificationsMain(argc, argv); |
| 270 } | 265 } |
| OLD | NEW |