Chromium Code Reviews| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 // output arguments, |error_code|, |response_code|, and |response|, are used | 44 // output arguments, |error_code|, |response_code|, and |response|, are used |
| 45 // to pass data back to the caller. The command has failed if the value | 45 // to pass data back to the caller. The command has failed if the value |
| 46 // pointed to by |error_code| is nonzero. |completion_closure| will be called | 46 // pointed to by |error_code| is nonzero. |completion_closure| will be called |
| 47 // immediately before return. | 47 // immediately before return. |
| 48 void HandleCommand(const std::string& request, | 48 void HandleCommand(const std::string& request, |
| 49 const base::Closure& completion_closure, | 49 const base::Closure& completion_closure, |
| 50 int* error_code, | 50 int* error_code, |
| 51 int* response_code, | 51 int* response_code, |
| 52 std::string* response); | 52 std::string* response); |
| 53 | 53 |
| 54 // Helpers for fetching the last Commit or Getupdates messages, respectively. | |
|
maxbogue
2016/04/01 22:30:48
s/Getupdates/GetUpdates
Nicolas Zea
2016/04/04 19:57:31
Done.
| |
| 55 // Returns true if the specified message existed, and false if no message has | |
| 56 // been received. | |
| 57 bool GetLastCommitMessage(sync_pb::ClientToServerMessage* message); | |
| 58 bool GetLastGetUpdatesMessage(sync_pb::ClientToServerMessage* message); | |
| 59 | |
| 54 // Creates a DicionaryValue representation of all entities present in the | 60 // Creates a DicionaryValue representation of all entities present in the |
| 55 // server. The dictionary keys are the strings generated by ModelTypeToString | 61 // server. The dictionary keys are the strings generated by ModelTypeToString |
| 56 // and the values are ListValues containing StringValue versions of entity | 62 // and the values are ListValues containing StringValue versions of entity |
| 57 // names. | 63 // names. |
| 58 scoped_ptr<base::DictionaryValue> GetEntitiesAsDictionaryValue(); | 64 scoped_ptr<base::DictionaryValue> GetEntitiesAsDictionaryValue(); |
| 59 | 65 |
| 60 // Returns all entities stored by the server of the given |model_type|. | 66 // Returns all entities stored by the server of the given |model_type|. |
| 61 // This method returns SyncEntity protocol buffer objects (instead of | 67 // This method returns SyncEntity protocol buffer objects (instead of |
| 62 // FakeServerEntity) so that callers can inspect datatype-specific data | 68 // FakeServerEntity) so that callers can inspect datatype-specific data |
| 63 // (e.g., the URL of a session tab). | 69 // (e.g., the URL of a session tab). |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 bool alternate_triggered_errors_; | 245 bool alternate_triggered_errors_; |
| 240 int request_counter_; | 246 int request_counter_; |
| 241 | 247 |
| 242 // FakeServer's observers. | 248 // FakeServer's observers. |
| 243 base::ObserverList<Observer, true> observers_; | 249 base::ObserverList<Observer, true> observers_; |
| 244 | 250 |
| 245 // When true, the server operates normally. When false, a failure is returned | 251 // When true, the server operates normally. When false, a failure is returned |
| 246 // on every request. This is used to simulate a network failure on the client. | 252 // on every request. This is used to simulate a network failure on the client. |
| 247 bool network_enabled_; | 253 bool network_enabled_; |
| 248 | 254 |
| 255 // The last received client to server messages. | |
| 256 sync_pb::ClientToServerMessage last_commit_message_; | |
| 257 sync_pb::ClientToServerMessage last_getupdates_message_; | |
| 258 | |
| 249 // Used to verify that FakeServer is only used from one thread. | 259 // Used to verify that FakeServer is only used from one thread. |
| 250 base::ThreadChecker thread_checker_; | 260 base::ThreadChecker thread_checker_; |
| 251 | 261 |
| 252 // Creates WeakPtr versions of the current FakeServer. This must be the last | 262 // Creates WeakPtr versions of the current FakeServer. This must be the last |
| 253 // data member! | 263 // data member! |
| 254 base::WeakPtrFactory<FakeServer> weak_ptr_factory_; | 264 base::WeakPtrFactory<FakeServer> weak_ptr_factory_; |
| 255 }; | 265 }; |
| 256 | 266 |
| 257 } // namespace fake_server | 267 } // namespace fake_server |
| 258 | 268 |
| 259 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ | 269 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ |
| OLD | NEW |