summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 00:19:00 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 00:19:00 +0000
commit1e659194cc2430c4169f7bc791c8541191dc9682 (patch)
treead14e4ea745a38db4f49117636a4c279d9356971 /sync
parenta7c827ea2fe601f353017bc1a68f68e3db849c71 (diff)
downloadchromium_src-1e659194cc2430c4169f7bc791c8541191dc9682.zip
chromium_src-1e659194cc2430c4169f7bc791c8541191dc9682.tar.gz
chromium_src-1e659194cc2430c4169f7bc791c8541191dc9682.tar.bz2
Prep for moving files into components/invalidation
Refactors some dependencies to prepare for an upcoming move of invalidator code from sync/internal_api/public/base to components/invalidation. Highlights include: - Remove some sync/ dependencies on invalidator_state.h - Refactor P2PInvalidator to not require model_type.h - Remove ModelType dependencies from invalidator_util.h. Introduce sync/tools/invalidation_helper.h and chrome/browser/sync/glue/invalidation_helper.h to replace it. TBR=ben BUG=259559 Review URL: https://codereview.chromium.org/403103002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284822 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/internal_api/public/base/invalidation_util.cc58
-rw-r--r--sync/internal_api/public/base/invalidation_util.h18
-rw-r--r--sync/internal_api/public/base/model_type.h5
-rw-r--r--sync/internal_api/sync_manager_impl.h1
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc4
-rw-r--r--sync/internal_api/test/fake_sync_manager.cc1
-rw-r--r--sync/tools/DEPS1
-rw-r--r--sync/tools/invalidation_helper.cc35
-rw-r--r--sync/tools/invalidation_helper.h21
-rw-r--r--sync/tools/sync_client.cc1
-rw-r--r--sync/tools/sync_listen_notifications.cc1
-rw-r--r--sync/tools/sync_tools.gyp2
12 files changed, 66 insertions, 82 deletions
diff --git a/sync/internal_api/public/base/invalidation_util.cc b/sync/internal_api/public/base/invalidation_util.cc
index dfa43bd..6433677 100644
--- a/sync/internal_api/public/base/invalidation_util.cc
+++ b/sync/internal_api/public/base/invalidation_util.cc
@@ -14,12 +14,6 @@
#include "google/cacheinvalidation/types.pb.h"
#include "sync/internal_api/public/base/invalidation.h"
-namespace invalidation {
-void PrintTo(const invalidation::ObjectId& id, std::ostream* os) {
- *os << syncer::ObjectIdToString(id);
-}
-} // namespace invalidation
-
namespace syncer {
bool ObjectIdLessThan::operator()(const invalidation::ObjectId& lhs,
@@ -47,22 +41,6 @@ bool InvalidationVersionLessThan::operator()(
return a.version() < b.version();
}
-bool RealModelTypeToObjectId(ModelType model_type,
- invalidation::ObjectId* object_id) {
- std::string notification_type;
- if (!RealModelTypeToNotificationType(model_type, &notification_type)) {
- return false;
- }
- object_id->Init(ipc::invalidation::ObjectSource::CHROME_SYNC,
- notification_type);
- return true;
-}
-
-bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id,
- ModelType* model_type) {
- return NotificationTypeToRealModelType(object_id.name(), model_type);
-}
-
scoped_ptr<base::DictionaryValue> ObjectIdToValue(
const invalidation::ObjectId& object_id) {
scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
@@ -92,40 +70,4 @@ std::string ObjectIdToString(
return str;
}
-ObjectIdSet ModelTypeSetToObjectIdSet(ModelTypeSet model_types) {
- ObjectIdSet ids;
- for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) {
- invalidation::ObjectId model_type_as_id;
- if (!RealModelTypeToObjectId(it.Get(), &model_type_as_id)) {
- DLOG(WARNING) << "Invalid model type " << it.Get();
- continue;
- }
- ids.insert(model_type_as_id);
- }
- return ids;
-}
-
-ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids) {
- ModelTypeSet model_types;
- for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
- ModelType model_type;
- if (!ObjectIdToRealModelType(*it, &model_type)) {
- DLOG(WARNING) << "Invalid object ID " << ObjectIdToString(*it);
- continue;
- }
- model_types.Put(model_type);
- }
- return model_types;
-}
-
-std::string InvalidationToString(
- const invalidation::Invalidation& invalidation) {
- std::stringstream ss;
- ss << "{ ";
- ss << "object_id: " << ObjectIdToString(invalidation.object_id()) << ", ";
- ss << "version: " << invalidation.version();
- ss << " }";
- return ss.str();
-}
-
} // namespace syncer
diff --git a/sync/internal_api/public/base/invalidation_util.h b/sync/internal_api/public/base/invalidation_util.h
index 5951ad8..2de2d20 100644
--- a/sync/internal_api/public/base/invalidation_util.h
+++ b/sync/internal_api/public/base/invalidation_util.h
@@ -7,14 +7,12 @@
#ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_
#define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_
-#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include "base/memory/scoped_ptr.h"
#include "sync/base/sync_export.h"
-#include "sync/internal_api/public/base/model_type.h"
namespace base {
class DictionaryValue;
@@ -25,10 +23,6 @@ namespace invalidation {
class Invalidation;
class ObjectId;
-// Gmock print helper
-SYNC_EXPORT_PRIVATE void PrintTo(const invalidation::ObjectId& id,
- std::ostream* os);
-
} // namespace invalidation
namespace syncer {
@@ -50,12 +44,6 @@ typedef std::set<invalidation::ObjectId, ObjectIdLessThan> ObjectIdSet;
typedef std::map<invalidation::ObjectId, int, ObjectIdLessThan>
ObjectIdCountMap;
-SYNC_EXPORT bool RealModelTypeToObjectId(ModelType model_type,
- invalidation::ObjectId* object_id);
-
-bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id,
- ModelType* model_type);
-
// Caller owns the returned DictionaryValue.
scoped_ptr<base::DictionaryValue> ObjectIdToValue(
const invalidation::ObjectId& object_id);
@@ -66,12 +54,6 @@ bool ObjectIdFromValue(const base::DictionaryValue& value,
SYNC_EXPORT_PRIVATE std::string ObjectIdToString(
const invalidation::ObjectId& object_id);
-SYNC_EXPORT_PRIVATE ObjectIdSet ModelTypeSetToObjectIdSet(ModelTypeSet models);
-ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids);
-
-std::string InvalidationToString(
- const invalidation::Invalidation& invalidation);
-
} // namespace syncer
#endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h
index 9132526..56824e4 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -298,8 +298,9 @@ SYNC_EXPORT std::string ModelTypeToRootTag(ModelType type);
// subscribing to server-issued notifications). Returns true iff
// |model_type| was a real model type and |notification_type| was
// filled in.
-bool RealModelTypeToNotificationType(ModelType model_type,
- std::string* notification_type);
+SYNC_EXPORT bool RealModelTypeToNotificationType(
+ ModelType model_type,
+ std::string* notification_type);
// Converts a notification type to a real model type. Returns true
// iff |notification_type| was the notification type of a real model
diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h
index 3037535..ae8d956 100644
--- a/sync/internal_api/sync_manager_impl.h
+++ b/sync/internal_api/sync_manager_impl.h
@@ -20,7 +20,6 @@
#include "sync/internal_api/js_sync_encryption_handler_observer.h"
#include "sync/internal_api/js_sync_manager_observer.h"
#include "sync/internal_api/protocol_event_buffer.h"
-#include "sync/internal_api/public/base/invalidator_state.h"
#include "sync/internal_api/public/sync_context_proxy.h"
#include "sync/internal_api/public/sync_manager.h"
#include "sync/internal_api/public/user_share.h"
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index 14ee50c..f5533dd 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -977,9 +977,9 @@ class SyncManagerTest : public testing::Test,
GetEncryptedTypes(trans->GetWrappedTrans());
}
- void SimulateInvalidatorStateChangeForTest(InvalidatorState state) {
+ void SimulateInvalidatorEnabledForTest(bool is_enabled) {
DCHECK(sync_manager_.thread_checker_.CalledOnValidThread());
- sync_manager_.SetInvalidatorEnabled(state == INVALIDATIONS_ENABLED);
+ sync_manager_.SetInvalidatorEnabled(is_enabled);
}
void SetProgressMarkerForType(ModelType type, bool set) {
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index e01c64a..9ed5fa0 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -14,7 +14,6 @@
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
-#include "sync/internal_api/public/base/invalidator_state.h"
#include "sync/internal_api/public/http_post_provider_factory.h"
#include "sync/internal_api/public/internal_components_factory.h"
#include "sync/internal_api/public/util/weak_handle.h"
diff --git a/sync/tools/DEPS b/sync/tools/DEPS
index ec5c93e..b132cd2 100644
--- a/sync/tools/DEPS
+++ b/sync/tools/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+components/invalidation",
+ "+google/cacheinvalidation",
"+jingle/notifier/base",
"+net",
"+sync/internal_api/public",
diff --git a/sync/tools/invalidation_helper.cc b/sync/tools/invalidation_helper.cc
new file mode 100644
index 0000000..61a4b87
--- /dev/null
+++ b/sync/tools/invalidation_helper.cc
@@ -0,0 +1,35 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/tools/invalidation_helper.h"
+
+#include "google/cacheinvalidation/types.pb.h"
+
+namespace syncer {
+
+bool RealModelTypeToObjectId(ModelType model_type,
+ invalidation::ObjectId* object_id) {
+ std::string notification_type;
+ if (!RealModelTypeToNotificationType(model_type, &notification_type)) {
+ return false;
+ }
+ object_id->Init(ipc::invalidation::ObjectSource::CHROME_SYNC,
+ notification_type);
+ return true;
+}
+
+ObjectIdSet ModelTypeSetToObjectIdSet(ModelTypeSet model_types) {
+ ObjectIdSet ids;
+ for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) {
+ invalidation::ObjectId model_type_as_id;
+ if (!RealModelTypeToObjectId(it.Get(), &model_type_as_id)) {
+ DLOG(WARNING) << "Invalid model type " << it.Get();
+ continue;
+ }
+ ids.insert(model_type_as_id);
+ }
+ return ids;
+}
+
+} // namespace syncer
diff --git a/sync/tools/invalidation_helper.h b/sync/tools/invalidation_helper.h
new file mode 100644
index 0000000..9d45253
--- /dev/null
+++ b/sync/tools/invalidation_helper.h
@@ -0,0 +1,21 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_TOOLS_INVALIDATION_HELPER_H_
+#define SYNC_TOOLS_INVALIDATION_HELPER_H_
+
+#include "google/cacheinvalidation/include/types.h"
+#include "sync/internal_api/public/base/invalidation_util.h"
+#include "sync/internal_api/public/base/model_type.h"
+
+namespace syncer {
+
+bool RealModelTypeToObjectId(ModelType model_type,
+ invalidation::ObjectId* object_id);
+
+ObjectIdSet ModelTypeSetToObjectIdSet(ModelTypeSet model_types);
+
+}
+
+#endif // SYNC_TOOLS_INVALIDATION_HELPER_H
diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc
index ca34f85..34ba338 100644
--- a/sync/tools/sync_client.cc
+++ b/sync/tools/sync_client.cc
@@ -44,6 +44,7 @@
#include "sync/js/js_event_details.h"
#include "sync/js/js_event_handler.h"
#include "sync/test/fake_encryptor.h"
+#include "sync/tools/invalidation_helper.h"
#include "sync/tools/null_invalidation_state_tracker.h"
#if defined(OS_MACOSX)
diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc
index 996647f..a7fb571 100644
--- a/sync/tools/sync_listen_notifications.cc
+++ b/sync/tools/sync_listen_notifications.cc
@@ -29,6 +29,7 @@
#include "net/url_request/url_request_test_util.h"
#include "sync/internal_api/public/base/invalidation_util.h"
#include "sync/internal_api/public/base/model_type.h"
+#include "sync/tools/invalidation_helper.h"
#include "sync/tools/null_invalidation_state_tracker.h"
#if defined(OS_MACOSX)
diff --git a/sync/tools/sync_tools.gyp b/sync/tools/sync_tools.gyp
index e6797b5..de1c339 100644
--- a/sync/tools/sync_tools.gyp
+++ b/sync/tools/sync_tools.gyp
@@ -27,6 +27,8 @@
'../sync.gyp:sync',
],
'sources': [
+ 'invalidation_helper.cc',
+ 'invalidation_helper.h',
'null_invalidation_state_tracker.cc',
'null_invalidation_state_tracker.h',
],