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

Unified Diff: components/sync/engine_impl/loopback_server/loopback_server.h

Issue 2887343002: wip 3 (Closed)
Patch Set: cleanup Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/BUILD.gn ('k') | components/sync/engine_impl/loopback_server/loopback_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/loopback_server/loopback_server.h
diff --git a/components/sync/engine_impl/loopback_server/loopback_server.h b/components/sync/engine_impl/loopback_server/loopback_server.h
index a69c99e4ac7c7da84751a21b88d3da0642352830..919bc6be82d5ff16fd0ca850910ed32873f07260 100644
--- a/components/sync/engine_impl/loopback_server/loopback_server.h
+++ b/components/sync/engine_impl/loopback_server/loopback_server.h
@@ -22,11 +22,25 @@
#include "components/sync/protocol/loopback_server.pb.h"
#include "components/sync/protocol/sync.pb.h"
+namespace fake_server {
+class FakeServer;
+}
+
namespace syncer {
// A loopback version of the Sync server used for local profile serialization.
class LoopbackServer {
public:
+ class ObserverForTests {
+ public:
+ virtual ~ObserverForTests() {}
+
+ // Called after the server has processed a successful commit. The types
+ // updated as part of the commit are passed in |committed_model_types|.
+ virtual void OnCommit(const std::string& committer_id,
+ syncer::ModelTypeSet committed_model_types) = 0;
+ };
+
explicit LoopbackServer(const base::FilePath& persistent_file);
virtual ~LoopbackServer();
@@ -40,6 +54,9 @@ class LoopbackServer {
std::string* response);
private:
+ // Allow the FakeServer decorator to inspect the internals of this class.
+ friend class fake_server::FakeServer;
+
using EntityMap =
std::map<std::string, std::unique_ptr<LoopbackServerEntity>>;
@@ -102,6 +119,32 @@ class LoopbackServer {
// Returns the store birthday.
std::string GetStoreBirthday() const;
+ // Returns all entities stored by the server of the given |model_type|.
+ // This method returns SyncEntity protocol buffer objects (instead of
+ // FakeServerEntity) so that callers can inspect datatype-specific data
+ // (e.g., the URL of a session tab).
+ std::vector<sync_pb::SyncEntity> GetSyncEntitiesByModelType(
+ syncer::ModelType model_type);
+
+ // Creates a DicionaryValue representation of all entities present in the
+ // server. The dictionary keys are the strings generated by ModelTypeToString
+ // and the values are ListValues containing StringValue versions of entity
+ // names. Used by test to verify the contents of the server state.
+ std::unique_ptr<base::DictionaryValue> GetEntitiesAsDictionaryValue();
+
+ // Modifies the entity on the server with the given |id|. The entity's
+ // EntitySpecifics are replaced with |updated_specifics| and its version is
+ // updated. If the given |id| does not exist or the ModelType of
+ // |updated_specifics| does not match the entity, false is returned.
+ // Otherwise, true is returned to represent a successful modification.
+ //
+ // This method sometimes updates entity data beyond EntitySpecifics. For
+ // example, in the case of a bookmark, changing the BookmarkSpecifics title
+ // field will modify the top-level entity's name field.
+ // This method is only used in tests.
+ bool ModifyEntitySpecifics(const std::string& id,
+ const sync_pb::EntitySpecifics& updated_specifics);
+
// Serializes the server state to |proto|.
void SerializeState(sync_pb::LoopbackServerProto* proto) const;
@@ -114,6 +157,10 @@ class LoopbackServer {
// Loads all entities and server state from a protobuf file in |filename|.
bool LoadStateFromFile(const base::FilePath& filename);
+ void set_observer_for_tests(ObserverForTests* observer) {
+ observer_for_tests_ = observer;
+ }
+
// This is the last version number assigned to an entity. The next entity will
// have a version number of version_ + 1.
int64_t version_;
@@ -128,6 +175,9 @@ class LoopbackServer {
// Used to verify that LoopbackServer is only used from one thread.
base::ThreadChecker thread_checker_;
+
+ // Used to observe the completion of commit messages for the sake of testing.
+ ObserverForTests* observer_for_tests_;
};
} // namespace syncer
« no previous file with comments | « components/sync/BUILD.gn ('k') | components/sync/engine_impl/loopback_server/loopback_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698