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

Unified Diff: chrome/browser/sync/glue/nigori_change_processor.cc

Issue 10827266: [Sync] Add SyncEncryptionHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/glue/nigori_change_processor.cc
diff --git a/chrome/browser/sync/glue/nigori_change_processor.cc b/chrome/browser/sync/glue/nigori_change_processor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..971346a9f02242cd5adabf0cdc42d00e55af54af
--- /dev/null
+++ b/chrome/browser/sync/glue/nigori_change_processor.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 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/nigori_change_processor.h"
+
+#include "base/tracked_objects.h"
+#include "sync/internal_api/public/read_node.h"
+#include "sync/internal_api/public/read_transaction.h"
+#include "sync/internal_api/public/sync_encryption_handler.h"
+#include "sync/internal_api/public/user_share.h"
+#include "sync/internal_api/public/util/experiments.h"
+#include "sync/protocol/nigori_specifics.pb.h"
+
+namespace browser_sync {
+
+NigoriChangeProcessor::NigoriChangeProcessor(
+ syncer::SyncEncryptionHandler* encryption_handler)
+ : user_share_(NULL),
+ encryption_handler_(encryption_handler) {
+}
+NigoriChangeProcessor::~NigoriChangeProcessor() {}
+
+void NigoriChangeProcessor::AssociateModels(syncer::UserShare* user_share) {
+ user_share_ = user_share;
+ encryption_handler_->ReloadNigori();
+}
+
+void NigoriChangeProcessor::DisassociateModels() {
+ user_share_ = NULL;
+ encryption_handler_ = NULL;
+}
+
+bool NigoriChangeProcessor::ReceivedExperiments(
+ syncer::Experiments* experiments) {
+ if (!user_share_)
+ return false; // Tests may not always have user shares.
+ syncer::ReadTransaction trans(FROM_HERE, user_share_);
+ syncer::ReadNode node(&trans);
+ if (node.InitByTagLookup(syncer::kNigoriTag) != syncer::BaseNode::INIT_OK) {
+ DVLOG(1) << "Couldn't find Nigori node.";
+ return false;
+ }
+ bool found_experiment = false;
+ if (node.GetNigoriSpecifics().sync_tab_favicons()) {
+ experiments->sync_tab_favicons = true;
+ found_experiment = true;
+ }
+ return found_experiment;
+}
+
+} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698