• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "jingle/notifier/base/notification_method.h"
6 
7 #include "base/logging.h"
8 
9 namespace notifier {
10 
11 const NotificationMethod kDefaultNotificationMethod = NOTIFICATION_SERVER;
12 
NotificationMethodToString(NotificationMethod notification_method)13 std::string NotificationMethodToString(
14     NotificationMethod notification_method) {
15   switch (notification_method) {
16     case NOTIFICATION_P2P:
17       return "NOTIFICATION_P2P";
18       break;
19     case NOTIFICATION_SERVER:
20       return "NOTIFICATION_SERVER";
21       break;
22     default:
23       LOG(WARNING) << "Unknown value for notification method: "
24                    << notification_method;
25       break;
26   }
27   return "<unknown notification method>";
28 }
29 
StringToNotificationMethod(const std::string & str)30 NotificationMethod StringToNotificationMethod(const std::string& str) {
31   if (str == "p2p") {
32     return NOTIFICATION_P2P;
33   } else if (str == "server") {
34     return NOTIFICATION_SERVER;
35   }
36   LOG(WARNING) << "Unknown notification method \"" << str
37                << "\"; using method "
38                << NotificationMethodToString(kDefaultNotificationMethod);
39   return kDefaultNotificationMethod;
40 }
41 
42 }  // namespace notifier
43