summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/extension_data.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-07-29 17:14:53 +0100
committerBen Murdoch <benm@google.com>2010-08-04 14:29:45 +0100
commitc407dc5cd9bdc5668497f21b26b09d988ab439de (patch)
tree7eaf8707c0309516bdb042ad976feedaf72b0bb1 /chrome/browser/sync/glue/extension_data.cc
parent0998b1cdac5733f299c12d88bc31ef9c8035b8fa (diff)
downloadexternal_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.zip
external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.gz
external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.bz2
Merge Chromium src@r53293
Change-Id: Ia79acf8670f385cee48c45b0a75371d8e950af34
Diffstat (limited to 'chrome/browser/sync/glue/extension_data.cc')
-rw-r--r--chrome/browser/sync/glue/extension_data.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/browser/sync/glue/extension_data.cc b/chrome/browser/sync/glue/extension_data.cc
new file mode 100644
index 0000000..eb4fea6
--- /dev/null
+++ b/chrome/browser/sync/glue/extension_data.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2010 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 "chrome/browser/sync/glue/extension_data.h"
+
+#include "base/logging.h"
+#include "chrome/browser/sync/glue/extension_util.h"
+
+namespace browser_sync {
+
+ExtensionData ExtensionData::FromData(
+ Source source, const sync_pb::ExtensionSpecifics& data) {
+ DcheckIsExtensionSpecificsValid(data);
+ ExtensionData extension_data;
+ extension_data.merged_data_ = extension_data.source_data_[source] = data;
+ DCHECK(AreExtensionSpecificsEqual(extension_data.merged_data(), data));
+ DCHECK(!extension_data.NeedsUpdate(source));
+ return extension_data;
+}
+
+const sync_pb::ExtensionSpecifics& ExtensionData::merged_data() const {
+ DcheckIsExtensionSpecificsValid(merged_data_);
+ return merged_data_;
+}
+
+bool ExtensionData::NeedsUpdate(Source source) const {
+ SourceDataMap::const_iterator it = source_data_.find(source);
+ return
+ (it == source_data_.end()) ||
+ !AreExtensionSpecificsEqual(it->second, merged_data_);
+}
+
+void ExtensionData::SetData(
+ Source source, bool merge_user_properties,
+ const sync_pb::ExtensionSpecifics& data) {
+ DcheckIsExtensionSpecificsValid(data);
+ source_data_[source] = data;
+ MergeExtensionSpecifics(data, merge_user_properties, &merged_data_);
+ DcheckIsExtensionSpecificsValid(merged_data_);
+}
+
+void ExtensionData::ResolveData(Source source) {
+ source_data_[source] = merged_data_;
+ DCHECK(!NeedsUpdate(source));
+}
+
+ExtensionData::ExtensionData() {}
+
+} // namespace browser_sync