OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "google_apis/gcm/engine/account_mapping.h" | 5 #include "google_apis/gcm/engine/account_mapping.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
10 | 12 |
11 namespace gcm { | 13 namespace gcm { |
12 | 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 const char kSeparator[] = "&"; | 17 const char kSeparator[] = "&"; |
16 const uint32 kEmailIndex = 0; | 18 const uint32_t kEmailIndex = 0; |
17 const uint32 kStatusIndex = 1; | 19 const uint32_t kStatusIndex = 1; |
18 const uint32 kStatusChangeTimestampIndex = 2; | 20 const uint32_t kStatusChangeTimestampIndex = 2; |
19 const uint32 kSizeWithNoMessage = kStatusChangeTimestampIndex + 1; | 21 const uint32_t kSizeWithNoMessage = kStatusChangeTimestampIndex + 1; |
20 const uint32 kMessageIdIndex = 3; | 22 const uint32_t kMessageIdIndex = 3; |
21 const uint32 kSizeWithMessage = kMessageIdIndex + 1; | 23 const uint32_t kSizeWithMessage = kMessageIdIndex + 1; |
22 | 24 |
23 const char kStatusNew[] = "new"; | 25 const char kStatusNew[] = "new"; |
24 const char kStatusAdding[] = "adding"; | 26 const char kStatusAdding[] = "adding"; |
25 const char kStatusMapped[] = "mapped"; | 27 const char kStatusMapped[] = "mapped"; |
26 const char kStatusRemoving[] = "removing"; | 28 const char kStatusRemoving[] = "removing"; |
27 | 29 |
28 std::string StatusToString(AccountMapping::MappingStatus status) { | 30 std::string StatusToString(AccountMapping::MappingStatus status) { |
29 switch (status) { | 31 switch (status) { |
30 case AccountMapping::NEW: | 32 case AccountMapping::NEW: |
31 return kStatusNew; | 33 return kStatusNew; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 if (values.size() == kSizeWithMessage && values[kMessageIdIndex].empty()) | 99 if (values.size() == kSizeWithMessage && values[kMessageIdIndex].empty()) |
98 return false; | 100 return false; |
99 | 101 |
100 MappingStatus temp_status; | 102 MappingStatus temp_status; |
101 if (!StringToStatus(values[kStatusIndex], &temp_status)) | 103 if (!StringToStatus(values[kStatusIndex], &temp_status)) |
102 return false; | 104 return false; |
103 | 105 |
104 if (values.size() == kSizeWithNoMessage && temp_status == ADDING) | 106 if (values.size() == kSizeWithNoMessage && temp_status == ADDING) |
105 return false; | 107 return false; |
106 | 108 |
107 int64 status_change_ts_internal = 0LL; | 109 int64_t status_change_ts_internal = 0LL; |
108 if (!base::StringToInt64(values[kStatusChangeTimestampIndex], | 110 if (!base::StringToInt64(values[kStatusChangeTimestampIndex], |
109 &status_change_ts_internal)) { | 111 &status_change_ts_internal)) { |
110 return false; | 112 return false; |
111 } | 113 } |
112 | 114 |
113 status_change_timestamp = | 115 status_change_timestamp = |
114 base::Time::FromInternalValue(status_change_ts_internal); | 116 base::Time::FromInternalValue(status_change_ts_internal); |
115 status = temp_status; | 117 status = temp_status; |
116 email = values[kEmailIndex]; | 118 email = values[kEmailIndex]; |
117 access_token.clear(); | 119 access_token.clear(); |
118 | 120 |
119 if (values.size() == kSizeWithMessage) | 121 if (values.size() == kSizeWithMessage) |
120 last_message_id = values[kMessageIdIndex]; | 122 last_message_id = values[kMessageIdIndex]; |
121 else | 123 else |
122 last_message_id.clear(); | 124 last_message_id.clear(); |
123 | 125 |
124 return true; | 126 return true; |
125 } | 127 } |
126 | 128 |
127 } // namespace gcm | 129 } // namespace gcm |
OLD | NEW |