| 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 #ifndef CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ | 5 #ifndef CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ |
| 6 #define CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ | 6 #define CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 namespace browser_sync { | 10 namespace browser_sync { |
| 11 | 11 |
| 12 // This is the matrix for the interaction between clients with | 12 // This is the matrix for the interaction between clients with |
| 13 // different notification methods: | 13 // different notification methods (except for NOTIFICATION_SERVER): |
| 14 // | 14 // |
| 15 // Listen | 15 // Listen |
| 16 // L T N | 16 // L T N |
| 17 // +-------+ | 17 // +-------+ |
| 18 // L | E E E | | 18 // L | E E E | |
| 19 // Send T | Y Y Y | | 19 // Send T | Y Y Y | |
| 20 // N | E Y Y | | 20 // N | E Y Y | |
| 21 // +-------+ | 21 // +-------+ |
| 22 // | 22 // |
| 23 // 'Y' means a client listening with the column notification method | 23 // 'Y' means a client listening with the column notification method |
| 24 // will receive notifications from a client sending with the row | 24 // will receive notifications from a client sending with the row |
| 25 // notification method. 'E' means means that the notification will be | 25 // notification method. 'E' means means that the notification will be |
| 26 // an empty one, which may be dropped by the server in the future. | 26 // an empty one, which may be dropped by the server in the future. |
| 27 // |
| 28 // As for NOTIFICATION_SERVER, server-issued notifications will also |
| 29 // simulate a peer-issued notification, so that any client with |
| 30 // NOTIFICATION_TRANSITIONAL or NOTIFICATION_NEW will be able to |
| 31 // receive those, too. This support will be removed once everyone is |
| 32 // on NOTIFICATION_SERVER. |
| 27 | 33 |
| 28 enum NotificationMethod { | 34 enum NotificationMethod { |
| 29 // Old, broken notification method. Works only if notification | 35 // Old, broken notification method. Works only if notification |
| 30 // servers don't drop empty notifications. | 36 // servers don't drop empty notifications. |
| 31 NOTIFICATION_LEGACY, | 37 NOTIFICATION_LEGACY, |
| 32 // Compatible with new notifications. Also compatible with legacy | 38 // Compatible with new notifications. Also compatible with legacy |
| 33 // notifications if the notification servers don't drop empty | 39 // notifications if the notification servers don't drop empty |
| 34 // notifications. | 40 // notifications. |
| 35 NOTIFICATION_TRANSITIONAL, | 41 NOTIFICATION_TRANSITIONAL, |
| 36 // New, ideal notification method. Compatible only with | 42 // New notification method. Compatible only with transitional |
| 37 // transitional notifications. | 43 // notifications. |
| 44 // |
| 45 // NOTE: "New" is kind of a misnomer, as it refers only to |
| 46 // peer-issued notifications; the plan is to migrate everyone to |
| 47 // using NOTIFICATION_SERVER. |
| 38 NOTIFICATION_NEW, | 48 NOTIFICATION_NEW, |
| 49 |
| 50 // Server-issued notifications. Compatible only with transitional |
| 51 // notifications. |
| 52 NOTIFICATION_SERVER, |
| 39 }; | 53 }; |
| 40 | 54 |
| 41 extern const NotificationMethod kDefaultNotificationMethod; | 55 extern const NotificationMethod kDefaultNotificationMethod; |
| 42 | 56 |
| 43 std::string NotificationMethodToString( | 57 std::string NotificationMethodToString( |
| 44 NotificationMethod notification_method); | 58 NotificationMethod notification_method); |
| 45 | 59 |
| 46 // If the given string is not one of "legacy", "transitional", or | 60 // If the given string is not one of "legacy", "transitional", "new", |
| 47 // "new", returns kDefaultNotificationMethod. | 61 // or "server", returns kDefaultNotificationMethod. |
| 48 NotificationMethod StringToNotificationMethod(const std::string& str); | 62 NotificationMethod StringToNotificationMethod(const std::string& str); |
| 49 | 63 |
| 50 } // namespace browser_sync | 64 } // namespace browser_sync |
| 51 | 65 |
| 52 #endif // CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ | 66 #endif // CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ |
| 53 | 67 |
| OLD | NEW |