| 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/notification_method.h" | 5 #include "chrome/browser/sync/notification_method.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace browser_sync { | 9 namespace browser_sync { |
| 10 | 10 |
| 11 // TODO(akalin): Eventually change this to NOTIFICATION_NEW. | 11 // TODO(akalin): Eventually change this to NOTIFICATION_NEW. |
| 12 const NotificationMethod kDefaultNotificationMethod = | 12 const NotificationMethod kDefaultNotificationMethod = |
| 13 NOTIFICATION_TRANSITIONAL; | 13 NOTIFICATION_TRANSITIONAL; |
| 14 | 14 |
| 15 std::string NotificationMethodToString( | 15 std::string NotificationMethodToString( |
| 16 NotificationMethod notification_method) { | 16 NotificationMethod notification_method) { |
| 17 switch (notification_method) { | 17 switch (notification_method) { |
| 18 case NOTIFICATION_LEGACY: | 18 case NOTIFICATION_LEGACY: |
| 19 return "NOTIFICATION_LEGACY"; | 19 return "NOTIFICATION_LEGACY"; |
| 20 break; | 20 break; |
| 21 case NOTIFICATION_TRANSITIONAL: | 21 case NOTIFICATION_TRANSITIONAL: |
| 22 return "NOTIFICATION_TRANSITIONAL"; | 22 return "NOTIFICATION_TRANSITIONAL"; |
| 23 break; | 23 break; |
| 24 case NOTIFICATION_NEW: | 24 case NOTIFICATION_NEW: |
| 25 return "NOTIFICATION_NEW"; | 25 return "NOTIFICATION_NEW"; |
| 26 break; | 26 break; |
| 27 case NOTIFICATION_SERVER: |
| 28 return "NOTIFICATION_SERVER"; |
| 29 break; |
| 27 default: | 30 default: |
| 28 LOG(WARNING) << "Unknown value for notification method: " | 31 LOG(WARNING) << "Unknown value for notification method: " |
| 29 << notification_method; | 32 << notification_method; |
| 30 break; | 33 break; |
| 31 } | 34 } |
| 32 return "<unknown notification method>"; | 35 return "<unknown notification method>"; |
| 33 } | 36 } |
| 34 | 37 |
| 35 NotificationMethod StringToNotificationMethod(const std::string& str) { | 38 NotificationMethod StringToNotificationMethod(const std::string& str) { |
| 36 if (str == "legacy") { | 39 if (str == "legacy") { |
| 37 return NOTIFICATION_LEGACY; | 40 return NOTIFICATION_LEGACY; |
| 38 } else if (str == "transitional") { | 41 } else if (str == "transitional") { |
| 39 return NOTIFICATION_TRANSITIONAL; | 42 return NOTIFICATION_TRANSITIONAL; |
| 40 } else if (str == "new") { | 43 } else if (str == "new") { |
| 41 return NOTIFICATION_NEW; | 44 return NOTIFICATION_NEW; |
| 45 } else if (str == "server") { |
| 46 return NOTIFICATION_SERVER; |
| 42 } | 47 } |
| 43 LOG(WARNING) << "Unknown notification method \"" << str | 48 LOG(WARNING) << "Unknown notification method \"" << str |
| 44 << "\"; using method " | 49 << "\"; using method " |
| 45 << NotificationMethodToString(kDefaultNotificationMethod); | 50 << NotificationMethodToString(kDefaultNotificationMethod); |
| 46 return kDefaultNotificationMethod; | 51 return kDefaultNotificationMethod; |
| 47 } | 52 } |
| 48 | 53 |
| 49 } // namespace browser_sync | 54 } // namespace browser_sync |
| OLD | NEW |