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 SYNC_TEST_ENGINE_MOCK_COMMIT_QUEUE_H_ | 5 #ifndef SYNC_TEST_ENGINE_MOCK_COMMIT_QUEUE_H_ |
6 #define SYNC_TEST_ENGINE_MOCK_COMMIT_QUEUE_H_ | 6 #define SYNC_TEST_ENGINE_MOCK_COMMIT_QUEUE_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <map> | 11 #include <map> |
9 #include <string> | 12 #include <string> |
10 #include <vector> | 13 #include <vector> |
11 | 14 |
12 #include "base/macros.h" | 15 #include "base/macros.h" |
13 #include "sync/engine/commit_queue.h" | 16 #include "sync/engine/commit_queue.h" |
14 #include "sync/internal_api/public/non_blocking_sync_common.h" | 17 #include "sync/internal_api/public/non_blocking_sync_common.h" |
15 | 18 |
16 namespace syncer_v2 { | 19 namespace syncer_v2 { |
17 | 20 |
(...skipping 20 matching lines...) Expand all Loading... |
38 // Functions to produce state as though it came from a real server and had | 41 // Functions to produce state as though it came from a real server and had |
39 // been filtered through a real CommitQueue. | 42 // been filtered through a real CommitQueue. |
40 | 43 |
41 // Returns an UpdateResponseData representing an update received from | 44 // Returns an UpdateResponseData representing an update received from |
42 // the server. Updates server state accordingly. | 45 // the server. Updates server state accordingly. |
43 // | 46 // |
44 // The |version_offset| field can be used to emulate stale data (ie. versions | 47 // The |version_offset| field can be used to emulate stale data (ie. versions |
45 // going backwards), reflections and redeliveries (ie. several instances of | 48 // going backwards), reflections and redeliveries (ie. several instances of |
46 // the same version) or new updates. | 49 // the same version) or new updates. |
47 UpdateResponseData UpdateFromServer( | 50 UpdateResponseData UpdateFromServer( |
48 int64 version_offset, | 51 int64_t version_offset, |
49 const std::string& tag_hash, | 52 const std::string& tag_hash, |
50 const sync_pb::EntitySpecifics& specifics); | 53 const sync_pb::EntitySpecifics& specifics); |
51 | 54 |
52 // Returns an UpdateResponseData representing a tombstone update from the | 55 // Returns an UpdateResponseData representing a tombstone update from the |
53 // server. Updates server state accordingly. | 56 // server. Updates server state accordingly. |
54 UpdateResponseData TombstoneFromServer(int64 version_offset, | 57 UpdateResponseData TombstoneFromServer(int64_t version_offset, |
55 const std::string& tag_hash); | 58 const std::string& tag_hash); |
56 | 59 |
57 // Returns a commit response that indicates a successful commit of the | 60 // Returns a commit response that indicates a successful commit of the |
58 // given |request_data|. Updates server state accordingly. | 61 // given |request_data|. Updates server state accordingly. |
59 CommitResponseData SuccessfulCommitResponse( | 62 CommitResponseData SuccessfulCommitResponse( |
60 const CommitRequestData& request_data); | 63 const CommitRequestData& request_data); |
61 | 64 |
62 // Sets the encryption key name used for updates from the server. | 65 // Sets the encryption key name used for updates from the server. |
63 // (ie. the key other clients are using to encrypt their commits.) | 66 // (ie. the key other clients are using to encrypt their commits.) |
64 // The default value is an empty string, which indicates no encryption. | 67 // The default value is an empty string, which indicates no encryption. |
65 void SetServerEncryptionKey(const std::string& key_name); | 68 void SetServerEncryptionKey(const std::string& key_name); |
66 | 69 |
67 private: | 70 private: |
68 // Generate an ID string. | 71 // Generate an ID string. |
69 static std::string GenerateId(const std::string& tag_hash); | 72 static std::string GenerateId(const std::string& tag_hash); |
70 | 73 |
71 // Retrieve or set the server version. | 74 // Retrieve or set the server version. |
72 int64 GetServerVersion(const std::string& tag_hash); | 75 int64_t GetServerVersion(const std::string& tag_hash); |
73 void SetServerVersion(const std::string& tag_hash, int64 version); | 76 void SetServerVersion(const std::string& tag_hash, int64_t version); |
74 | 77 |
75 // A record of past commits requests. | 78 // A record of past commits requests. |
76 std::vector<CommitRequestDataList> commit_request_lists_; | 79 std::vector<CommitRequestDataList> commit_request_lists_; |
77 | 80 |
78 // Map of versions by client tag. | 81 // Map of versions by client tag. |
79 // This is an essential part of the mocked server state. | 82 // This is an essential part of the mocked server state. |
80 std::map<const std::string, int64> server_versions_; | 83 std::map<const std::string, int64_t> server_versions_; |
81 | 84 |
82 // Name of the encryption key in use on other clients. | 85 // Name of the encryption key in use on other clients. |
83 std::string server_encryption_key_name_; | 86 std::string server_encryption_key_name_; |
84 | 87 |
85 DISALLOW_COPY_AND_ASSIGN(MockCommitQueue); | 88 DISALLOW_COPY_AND_ASSIGN(MockCommitQueue); |
86 }; | 89 }; |
87 | 90 |
88 } // namespace syncer_v2 | 91 } // namespace syncer_v2 |
89 | 92 |
90 #endif // SYNC_TEST_ENGINE_MOCK_COMMIT_QUEUE_H_ | 93 #endif // SYNC_TEST_ENGINE_MOCK_COMMIT_QUEUE_H_ |
OLD | NEW |