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

Unified Diff: chrome/browser/sync/internal_api/syncapi_functions.cc

Issue 7633077: Refactor syncapi.h (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Set of patches to refactor syncapi.h Created 9 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/internal_api/syncapi_functions.cc
diff --git a/chrome/browser/sync/internal_api/syncapi_functions.cc b/chrome/browser/sync/internal_api/syncapi_functions.cc
new file mode 100644
index 0000000000000000000000000000000000000000..42554e547ad71df430359ade257b592867be8b43
--- /dev/null
+++ b/chrome/browser/sync/internal_api/syncapi_functions.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 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/internal_api/syncapi_functions.h"
+
+#include <string>
+
+#include "base/file_path.h"
+#include "chrome/browser/sync/internal_api/base_transaction.h"
+#include "chrome/browser/sync/internal_api/user_share.h"
+#include "chrome/browser/sync/syncable/directory_manager.h"
+#include "chrome/browser/sync/util/cryptographer.h"
+
+using browser_sync::Cryptographer;
+
+namespace sync_api {
+
+// Helper function that converts a PassphraseRequiredReason value to a string.
+std::string PassphraseRequiredReasonToString(
Nicolas Zea 2011/08/16 19:39:07 I think this should be in sync_manager.h (where pa
rlarocque 2011/08/16 22:19:19 Done.
+ PassphraseRequiredReason reason) {
+ switch (reason) {
+ case REASON_PASSPHRASE_NOT_REQUIRED:
+ return "REASON_PASSPHRASE_NOT_REQUIRED";
+ case REASON_ENCRYPTION:
+ return "REASON_ENCRYPTION";
+ case REASON_DECRYPTION:
+ return "REASON_DECRYPTION";
+ case REASON_SET_PASSPHRASE_FAILED:
+ return "REASON_SET_PASSPHRASE_FAILED";
+ default:
+ NOTREACHED();
+ return "INVALID_REASON";
+ }
+}
+
+// Helper function to determine if initial sync had ended for types.
+bool InitialSyncEndedForTypes(syncable::ModelTypeSet types,
Nicolas Zea 2011/08/16 19:39:07 This one too.
rlarocque 2011/08/16 22:19:19 Done.
+ sync_api::UserShare* share) {
+ syncable::ScopedDirLookup lookup(share->dir_manager.get(),
+ share->name);
+ if (!lookup.good()) {
+ DCHECK(false) << "ScopedDirLookup failed when checking initial sync";
+ return false;
+ }
+
+ for (syncable::ModelTypeSet::const_iterator i = types.begin();
+ i != types.end(); ++i) {
+ if (!lookup->initial_sync_ended_for_type(*i))
+ return false;
+ }
+ return true;
+}
+
+syncable::ModelTypeSet GetEncryptedTypes(
Nicolas Zea 2011/08/16 19:39:07 This can be in basetransaction.h
rlarocque 2011/08/16 22:19:19 Done. Now I can delete this file. Woo-hoo!
+ const sync_api::BaseTransaction* trans) {
+ Cryptographer* cryptographer = trans->GetCryptographer();
+ return cryptographer->GetEncryptedTypes();
+}
+
+} // namespace sync_api

Powered by Google App Engine
This is Rietveld 408576698