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

Unified Diff: components/sync/syncable/nigori_util.cc

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, 5 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/syncable/nigori_util.h ('k') | components/sync/syncable/nigori_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/syncable/nigori_util.cc
diff --git a/sync/syncable/nigori_util.cc b/components/sync/syncable/nigori_util.cc
similarity index 83%
rename from sync/syncable/nigori_util.cc
rename to components/sync/syncable/nigori_util.cc
index 2016a7ac9896401620d3471128cd9e43aae91eb0..96e687d0351dc7f0a63e8264fce11454ada10d58 100644
--- a/sync/syncable/nigori_util.cc
+++ b/components/sync/syncable/nigori_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/syncable/nigori_util.h"
+#include "components/sync/syncable/nigori_util.h"
#include <stddef.h>
#include <stdint.h>
@@ -12,19 +12,18 @@
#include <vector>
#include "base/json/json_writer.h"
-#include "sync/syncable/directory.h"
-#include "sync/syncable/entry.h"
-#include "sync/syncable/mutable_entry.h"
-#include "sync/syncable/nigori_handler.h"
-#include "sync/syncable/syncable_util.h"
-#include "sync/syncable/syncable_write_transaction.h"
-#include "sync/util/cryptographer.h"
+#include "components/sync/base/cryptographer.h"
+#include "components/sync/syncable/directory.h"
+#include "components/sync/syncable/entry.h"
+#include "components/sync/syncable/mutable_entry.h"
+#include "components/sync/syncable/nigori_handler.h"
+#include "components/sync/syncable/syncable_util.h"
+#include "components/sync/syncable/syncable_write_transaction.h"
namespace syncer {
namespace syncable {
-bool ProcessUnsyncedChangesForEncryption(
- WriteTransaction* const trans) {
+bool ProcessUnsyncedChangesForEncryption(WriteTransaction* const trans) {
NigoriHandler* nigori_handler = trans->directory()->GetNigoriHandler();
ModelTypeSet encrypted_types = nigori_handler->GetEncryptedTypes(trans);
Cryptographer* cryptographer = trans->directory()->GetCryptographer(trans);
@@ -51,9 +50,8 @@ bool ProcessUnsyncedChangesForEncryption(
return true;
}
-bool VerifyUnsyncedChangesAreEncrypted(
- BaseTransaction* const trans,
- ModelTypeSet encrypted_types) {
+bool VerifyUnsyncedChangesAreEncrypted(BaseTransaction* const trans,
+ ModelTypeSet encrypted_types) {
std::vector<int64_t> handles;
GetUnsyncedEntries(trans, &handles);
for (size_t i = 0; i < handles.size(); ++i) {
@@ -68,8 +66,7 @@ bool VerifyUnsyncedChangesAreEncrypted(
return true;
}
-bool EntryNeedsEncryption(ModelTypeSet encrypted_types,
- const Entry& entry) {
+bool EntryNeedsEncryption(ModelTypeSet encrypted_types, const Entry& entry) {
if (!entry.GetUniqueServerTag().empty())
return false; // We don't encrypt unique server nodes.
ModelType type = entry.GetModelType();
@@ -94,10 +91,9 @@ bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types,
}
// Mainly for testing.
-bool VerifyDataTypeEncryptionForTest(
- BaseTransaction* const trans,
- ModelType type,
- bool is_encrypted) {
+bool VerifyDataTypeEncryptionForTest(BaseTransaction* const trans,
+ ModelType type,
+ bool is_encrypted) {
Cryptographer* cryptographer = trans->directory()->GetCryptographer(trans);
if (type == PASSWORDS || IsControlType(type)) {
NOTREACHED();
@@ -148,18 +144,17 @@ bool VerifyDataTypeEncryptionForTest(
return true;
}
-bool UpdateEntryWithEncryption(
- BaseTransaction* const trans,
- const sync_pb::EntitySpecifics& new_specifics,
- syncable::MutableEntry* entry) {
+bool UpdateEntryWithEncryption(BaseTransaction* const trans,
+ const sync_pb::EntitySpecifics& new_specifics,
+ syncable::MutableEntry* entry) {
NigoriHandler* nigori_handler = trans->directory()->GetNigoriHandler();
Cryptographer* cryptographer = trans->directory()->GetCryptographer(trans);
ModelType type = GetModelTypeFromSpecifics(new_specifics);
DCHECK_GE(type, FIRST_REAL_MODEL_TYPE);
const sync_pb::EntitySpecifics& old_specifics = entry->GetSpecifics();
const ModelTypeSet encrypted_types =
- nigori_handler?
- nigori_handler->GetEncryptedTypes(trans) : ModelTypeSet();
+ nigori_handler ? nigori_handler->GetEncryptedTypes(trans)
+ : ModelTypeSet();
// It's possible the nigori lost the set of encrypted types. If the current
// specifics are already encrypted, we want to ensure we continue encrypting.
bool was_encrypted = old_specifics.has_encrypted();
@@ -180,17 +175,14 @@ bool UpdateEntryWithEncryption(
std::string info;
base::JSONWriter::WriteWithOptions(
*value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &info);
- DVLOG(2) << "Encrypting specifics of type "
- << ModelTypeToString(type)
- << " with content: "
- << info;
+ DVLOG(2) << "Encrypting specifics of type " << ModelTypeToString(type)
+ << " with content: " << info;
}
// Only copy over the old specifics if it is of the right type and already
// encrypted. The first time we encrypt a node we start from scratch, hence
// removing all the unencrypted data, but from then on we only want to
// update the node if the data changes or the encryption key changes.
- if (GetModelTypeFromSpecifics(old_specifics) == type &&
- was_encrypted) {
+ if (GetModelTypeFromSpecifics(old_specifics) == type && was_encrypted) {
generated_specifics.CopyFrom(old_specifics);
} else {
AddDefaultFieldValue(type, &generated_specifics);
@@ -207,8 +199,8 @@ bool UpdateEntryWithEncryption(
// It's possible this entry was encrypted but didn't properly overwrite the
// non_unique_name (see crbug.com/96314).
- bool encrypted_without_overwriting_name = (was_encrypted &&
- entry->GetNonUniqueName() != kEncryptedString);
+ bool encrypted_without_overwriting_name =
+ (was_encrypted && entry->GetNonUniqueName() != kEncryptedString);
// If we're encrypted but the name wasn't overwritten properly we still want
// to rewrite the entry, irrespective of whether the specifics match.
@@ -234,8 +226,7 @@ bool UpdateEntryWithEncryption(
}
}
entry->PutSpecifics(generated_specifics);
- DVLOG(1) << "Overwriting specifics of type "
- << ModelTypeToString(type)
+ DVLOG(1) << "Overwriting specifics of type " << ModelTypeToString(type)
<< " and marking for syncing.";
syncable::MarkForSyncing(entry);
return true;
@@ -246,30 +237,22 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types,
sync_pb::NigoriSpecifics* nigori) {
nigori->set_encrypt_everything(encrypt_everything);
static_assert(37 == MODEL_TYPE_COUNT, "update encrypted types");
- nigori->set_encrypt_bookmarks(
- encrypted_types.Has(BOOKMARKS));
- nigori->set_encrypt_preferences(
- encrypted_types.Has(PREFERENCES));
- nigori->set_encrypt_autofill_profile(
- encrypted_types.Has(AUTOFILL_PROFILE));
+ nigori->set_encrypt_bookmarks(encrypted_types.Has(BOOKMARKS));
+ nigori->set_encrypt_preferences(encrypted_types.Has(PREFERENCES));
+ nigori->set_encrypt_autofill_profile(encrypted_types.Has(AUTOFILL_PROFILE));
nigori->set_encrypt_autofill(encrypted_types.Has(AUTOFILL));
nigori->set_encrypt_autofill_wallet_metadata(
encrypted_types.Has(AUTOFILL_WALLET_METADATA));
nigori->set_encrypt_themes(encrypted_types.Has(THEMES));
- nigori->set_encrypt_typed_urls(
- encrypted_types.Has(TYPED_URLS));
+ nigori->set_encrypt_typed_urls(encrypted_types.Has(TYPED_URLS));
nigori->set_encrypt_extension_settings(
encrypted_types.Has(EXTENSION_SETTINGS));
- nigori->set_encrypt_extensions(
- encrypted_types.Has(EXTENSIONS));
- nigori->set_encrypt_search_engines(
- encrypted_types.Has(SEARCH_ENGINES));
+ nigori->set_encrypt_extensions(encrypted_types.Has(EXTENSIONS));
+ nigori->set_encrypt_search_engines(encrypted_types.Has(SEARCH_ENGINES));
nigori->set_encrypt_sessions(encrypted_types.Has(SESSIONS));
- nigori->set_encrypt_app_settings(
- encrypted_types.Has(APP_SETTINGS));
+ nigori->set_encrypt_app_settings(encrypted_types.Has(APP_SETTINGS));
nigori->set_encrypt_apps(encrypted_types.Has(APPS));
- nigori->set_encrypt_app_notifications(
- encrypted_types.Has(APP_NOTIFICATIONS));
+ nigori->set_encrypt_app_notifications(encrypted_types.Has(APP_NOTIFICATIONS));
nigori->set_encrypt_dictionary(encrypted_types.Has(DICTIONARY));
nigori->set_encrypt_favicon_images(encrypted_types.Has(FAVICON_IMAGES));
nigori->set_encrypt_favicon_tracking(encrypted_types.Has(FAVICON_TRACKING));
« no previous file with comments | « components/sync/syncable/nigori_util.h ('k') | components/sync/syncable/nigori_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698