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_FAKE_SERVER_FAKE_SERVER_H_ | 5 #ifndef SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ |
6 #define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ | 6 #define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // must be called if AddObserver was ever called with |observer|. | 109 // must be called if AddObserver was ever called with |observer|. |
110 void RemoveObserver(Observer* observer); | 110 void RemoveObserver(Observer* observer); |
111 | 111 |
112 // Undoes the effects of DisableNetwork. | 112 // Undoes the effects of DisableNetwork. |
113 void EnableNetwork(); | 113 void EnableNetwork(); |
114 | 114 |
115 // Forces every request to fail in a way that simulates a network failure. | 115 // Forces every request to fail in a way that simulates a network failure. |
116 // This can be used to trigger exponential backoff in the client. | 116 // This can be used to trigger exponential backoff in the client. |
117 void DisableNetwork(); | 117 void DisableNetwork(); |
118 | 118 |
| 119 // Returns the entity ID of the Bookmark Bar folder. |
| 120 std::string GetBookmarkBarFolderId() const; |
| 121 |
119 private: | 122 private: |
120 typedef std::map<std::string, FakeServerEntity*> EntityMap; | 123 typedef std::map<std::string, FakeServerEntity*> EntityMap; |
121 | 124 |
122 // Processes a GetUpdates call. | 125 // Processes a GetUpdates call. |
123 bool HandleGetUpdatesRequest(const sync_pb::GetUpdatesMessage& get_updates, | 126 bool HandleGetUpdatesRequest(const sync_pb::GetUpdatesMessage& get_updates, |
124 sync_pb::GetUpdatesResponse* response); | 127 sync_pb::GetUpdatesResponse* response); |
125 | 128 |
126 // Processes a Commit call. | 129 // Processes a Commit call. |
127 bool HandleCommitRequest(const sync_pb::CommitMessage& message, | 130 bool HandleCommitRequest(const sync_pb::CommitMessage& message, |
128 const std::string& invalidator_client_id, | 131 const std::string& invalidator_client_id, |
129 sync_pb::CommitResponse* response); | 132 sync_pb::CommitResponse* response); |
130 | 133 |
131 bool CreatePermanentBookmarkFolder(const char* server_tag, const char* name); | 134 // Creates and saves a permanent folder for Bookmarks (e.g., Bookmark Bar). |
| 135 bool CreatePermanentBookmarkFolder(const std::string& server_tag, |
| 136 const std::string& name); |
132 | 137 |
133 // Inserts the default permanent items in |entities_|. | 138 // Inserts the default permanent items in |entities_|. |
134 bool CreateDefaultPermanentItems(); | 139 bool CreateDefaultPermanentItems(); |
135 | 140 |
136 // Inserts the mobile bookmarks folder entity in |entities_|. | |
137 bool CreateMobileBookmarksPermanentItem(); | |
138 | |
139 // Saves a |entity| to |entities_|. | 141 // Saves a |entity| to |entities_|. |
140 void SaveEntity(FakeServerEntity* entity); | 142 void SaveEntity(FakeServerEntity* entity); |
141 | 143 |
142 // Commits a client-side SyncEntity to the server as a FakeServerEntity. | 144 // Commits a client-side SyncEntity to the server as a FakeServerEntity. |
143 // The client that sent the commit is identified via |client_guid|. The | 145 // The client that sent the commit is identified via |client_guid|. The |
144 // parent ID string present in |client_entity| should be ignored in favor | 146 // parent ID string present in |client_entity| should be ignored in favor |
145 // of |parent_id|. If the commit is successful, the entity's server ID string | 147 // of |parent_id|. If the commit is successful, the entity's server ID string |
146 // is returned and a new FakeServerEntity is saved in |entities_|. | 148 // is returned and a new FakeServerEntity is saved in |entities_|. |
147 std::string CommitEntity( | 149 std::string CommitEntity( |
148 const sync_pb::SyncEntity& client_entity, | 150 const sync_pb::SyncEntity& client_entity, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 ObserverList<Observer, true> observers_; | 209 ObserverList<Observer, true> observers_; |
208 | 210 |
209 // When true, the server operates normally. When false, a failure is returned | 211 // When true, the server operates normally. When false, a failure is returned |
210 // on every request. This is used to simulate a network failure on the client. | 212 // on every request. This is used to simulate a network failure on the client. |
211 bool network_enabled_; | 213 bool network_enabled_; |
212 }; | 214 }; |
213 | 215 |
214 } // namespace fake_server | 216 } // namespace fake_server |
215 | 217 |
216 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ | 218 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ |
OLD | NEW |