Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: components/sync/test/fake_server/fake_server.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_
6 #define SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ 6 #define COMPONENTS_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>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "sync/internal_api/public/base/model_type.h" 19 #include "components/sync/base/model_type.h"
20 #include "sync/protocol/sync.pb.h" 20 #include "components/sync/protocol/sync.pb.h"
21 #include "sync/test/fake_server/fake_server_entity.h" 21 #include "components/sync/test/fake_server/fake_server_entity.h"
22 22
23 namespace fake_server { 23 namespace fake_server {
24 24
25 // A fake version of the Sync server used for testing. This class is not thread 25 // A fake version of the Sync server used for testing. This class is not thread
26 // safe. 26 // safe.
27 class FakeServer { 27 class FakeServer {
28 public: 28 public:
29 class Observer { 29 class Observer {
30 public: 30 public:
31 virtual ~Observer() {} 31 virtual ~Observer() {}
32 32
33 // Called after FakeServer has processed a successful commit. The types 33 // Called after FakeServer has processed a successful commit. The types
34 // updated as part of the commit are passed in |committed_model_types|. 34 // updated as part of the commit are passed in |committed_model_types|.
35 virtual void OnCommit( 35 virtual void OnCommit(const std::string& committer_id,
36 const std::string& committer_id, 36 syncer::ModelTypeSet committed_model_types) = 0;
37 syncer::ModelTypeSet committed_model_types) = 0;
38 }; 37 };
39 38
40 FakeServer(); 39 FakeServer();
41 virtual ~FakeServer(); 40 virtual ~FakeServer();
42 41
43 // Handles a /command POST (with the given |request|) to the server. Three 42 // Handles a /command POST (with the given |request|) to the server. Three
44 // output arguments, |error_code|, |response_code|, and |response|, are used 43 // 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 44 // 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 45 // pointed to by |error_code| is nonzero. |completion_closure| will be called
47 // immediately before return. 46 // immediately before return.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Force the server to return |error_type| in the error_code field of 105 // Force the server to return |error_type| in the error_code field of
107 // ClientToServerResponse on all subsequent sync requests. This method should 106 // ClientToServerResponse on all subsequent sync requests. This method should
108 // not be called if TriggerActionableError has previously been called. Returns 107 // not be called if TriggerActionableError has previously been called. Returns
109 // true if error triggering was successfully configured. 108 // true if error triggering was successfully configured.
110 bool TriggerError(const sync_pb::SyncEnums::ErrorType& error_type); 109 bool TriggerError(const sync_pb::SyncEnums::ErrorType& error_type);
111 110
112 // Force the server to return the given data as part of the error field of 111 // Force the server to return the given data as part of the error field of
113 // ClientToServerResponse on all subsequent sync requests. This method should 112 // ClientToServerResponse on all subsequent sync requests. This method should
114 // not be called if TriggerError has previously been called. Returns true if 113 // not be called if TriggerError has previously been called. Returns true if
115 // error triggering was successfully configured. 114 // error triggering was successfully configured.
116 bool TriggerActionableError( 115 bool TriggerActionableError(const sync_pb::SyncEnums::ErrorType& error_type,
117 const sync_pb::SyncEnums::ErrorType& error_type, 116 const std::string& description,
118 const std::string& description, 117 const std::string& url,
119 const std::string& url, 118 const sync_pb::SyncEnums::Action& action);
120 const sync_pb::SyncEnums::Action& action);
121 119
122 // Instructs the server to send triggered errors on every other request 120 // Instructs the server to send triggered errors on every other request
123 // (starting with the first one after this call). This feature can be used to 121 // (starting with the first one after this call). This feature can be used to
124 // test the resiliency of the client when communicating with a problematic 122 // test the resiliency of the client when communicating with a problematic
125 // server or flaky network connection. This method should only be called 123 // server or flaky network connection. This method should only be called
126 // after a call to TriggerError or TriggerActionableError. Returns true if 124 // after a call to TriggerError or TriggerActionableError. Returns true if
127 // triggered error alternating was successful. 125 // triggered error alternating was successful.
128 bool EnableAlternatingTriggeredErrors(); 126 bool EnableAlternatingTriggeredErrors();
129 127
130 // Adds |observer| to FakeServer's observer list. This should be called 128 // Adds |observer| to FakeServer's observer list. This should be called
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Used to verify that FakeServer is only used from one thread. 258 // Used to verify that FakeServer is only used from one thread.
261 base::ThreadChecker thread_checker_; 259 base::ThreadChecker thread_checker_;
262 260
263 // Creates WeakPtr versions of the current FakeServer. This must be the last 261 // Creates WeakPtr versions of the current FakeServer. This must be the last
264 // data member! 262 // data member!
265 base::WeakPtrFactory<FakeServer> weak_ptr_factory_; 263 base::WeakPtrFactory<FakeServer> weak_ptr_factory_;
266 }; 264 };
267 265
268 } // namespace fake_server 266 } // namespace fake_server
269 267
270 #endif // SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_ 268 #endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_FAKE_SERVER_H_
OLDNEW
« no previous file with comments | « components/sync/test/fake_server/entity_builder_factory.cc ('k') | components/sync/test/fake_server/fake_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698