| 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 #ifndef GOOGLE_APIS_GCM_ENGINE_ACCOUNT_MAPPING_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_ACCOUNT_MAPPING_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_ACCOUNT_MAPPING_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_ACCOUNT_MAPPING_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "google_apis/gcm/base/gcm_export.h" | 12 #include "google_apis/gcm/base/gcm_export.h" |
| 13 | 13 |
| 14 namespace gcm { | 14 namespace gcm { |
| 15 | 15 |
| 16 // Stores information about Account mapping and a last message sent regarding | 16 // Stores information about Account mapping and a last message sent regarding |
| 17 // that mapping. | 17 // that mapping. |
| 18 struct GCM_EXPORT AccountMapping { | 18 struct GCM_EXPORT AccountMapping { |
| 19 // Status of the account mapping. | 19 // Status of the account mapping. |
| 20 enum MappingStatus { | 20 enum MappingStatus { |
| 21 NEW, // This is a new account mapping entry. | 21 NEW, // This is a new account mapping entry. |
| 22 ADDING, // A mapping message has been sent, but it has not been confirmed | 22 ADDING, // A mapping message has been sent, but it has not been confirmed |
| 23 // yet. | 23 // yet. |
| 24 MAPPED, // Account is mapped. At least one message has been confirmed to | 24 MAPPED, // Account is mapped. At least one message has been confirmed to |
| 25 // reached the GCM. | 25 // reached the GCM. |
| 26 REMOVING, // Account is removed, but a message removing the mapping has not | 26 REMOVING, // Account is removed, but a message removing the mapping has not |
| 27 // been confirmed yet. | 27 // been confirmed yet. |
| 28 REMOVED, // Account is removed, and at least one message has been | |
| 29 // confirmed to have reached the GCM. | |
| 30 }; | |
| 31 | |
| 32 // Indicates whether a message, if sent, was adding or removing account | |
| 33 // mapping. | |
| 34 enum MessageType { | |
| 35 MSG_NONE, // No message has been sent. | |
| 36 MSG_ADD, // Account was mapped to device by the message. | |
| 37 MSG_REMOVE, // Account mapping to device was removed by the message. | |
| 38 }; | 28 }; |
| 39 | 29 |
| 40 AccountMapping(); | 30 AccountMapping(); |
| 41 ~AccountMapping(); | 31 ~AccountMapping(); |
| 42 | 32 |
| 43 // Serializes account mapping to string without |account_id|, |status| or | 33 // Serializes account mapping to string without |account_id|, |status| or |
| 44 // |access_token|. | 34 // |access_token|. |
| 45 std::string SerializeAsString() const; | 35 std::string SerializeAsString() const; |
| 46 // Parses account mapping from store, without |account_id| or |access_token|. | 36 // Parses account mapping from store, without |account_id| or |access_token|. |
| 47 // |status| is infered. | 37 // |status| is infered. |
| 48 bool ParseFromString(const std::string& value); | 38 bool ParseFromString(const std::string& value); |
| 49 | 39 |
| 50 // Gaia ID of the account. (Acts as key for persistence.) | 40 // Gaia ID of the account. (Acts as key for persistence.) |
| 51 std::string account_id; | 41 std::string account_id; |
| 52 // Email address of the tracked account. | 42 // Email address of the tracked account. |
| 53 std::string email; | 43 std::string email; |
| 54 // OAuth2 access token used to authenticate mappings (not persisted). | 44 // OAuth2 access token used to authenticate mappings (not persisted). |
| 55 std::string access_token; | 45 std::string access_token; |
| 56 // Status of the account mapping (not persisted). | 46 // Status of the account mapping (not persisted). |
| 57 MappingStatus status; | 47 MappingStatus status; |
| 58 // Time of the mapping status change. | 48 // Time of the mapping status change. |
| 59 base::Time status_change_timestamp; | 49 base::Time status_change_timestamp; |
| 60 // Type of the last mapping message sent to GCM. | |
| 61 MessageType last_message_type; | |
| 62 // ID of the last mapping message sent to GCM. | 50 // ID of the last mapping message sent to GCM. |
| 63 std::string last_message_id; | 51 std::string last_message_id; |
| 64 }; | 52 }; |
| 65 | 53 |
| 66 } // namespace gcm | 54 } // namespace gcm |
| 67 | 55 |
| 68 #endif // GOOGLE_APIS_GCM_ENGINE_ACCOUNT_MAPPING_H_ | 56 #endif // GOOGLE_APIS_GCM_ENGINE_ACCOUNT_MAPPING_H_ |
| OLD | NEW |