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