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

Unified Diff: sync/engine/cryptographer_provider.h

Issue 413833002: sync: Introduce CryptographerProvider interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo fix and small cleanup Created 6 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 | « no previous file | sync/engine/cryptographer_provider.cc » ('j') | sync/engine/cryptographer_provider.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/cryptographer_provider.h
diff --git a/sync/engine/cryptographer_provider.h b/sync/engine/cryptographer_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..21c5b6445842fda4ce9cc081a7b4c2ade9c83529
--- /dev/null
+++ b/sync/engine/cryptographer_provider.h
@@ -0,0 +1,64 @@
+// 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_ENGINE_CRYPTOGRAPHER_PROVIDER_H_
+#define SYNC_ENGINE_CRYPTOGRAPHER_PROVIDER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "sync/base/sync_export.h"
+
+namespace syncer {
+
+class Cryptographer;
+class ScopedCryptographer;
+class ScopedCryptographerImpl;
+
+// An interface for providing clients with a ScopedCryptographer.
+//
+// Used to expose the syncable::Directory's cryptographer to clients that
+// would otherwise not have access to the Directory.
+class SYNC_EXPORT_PRIVATE CryptographerProvider {
+ public:
+ CryptographerProvider();
+ virtual ~CryptographerProvider();
+
+ virtual bool InitScopedCryptographer(ScopedCryptographer* scoped) = 0;
+};
+
+// A concrete class representing a cryptographer.
+//
+// Access to the cryptographer is lost when this class goes out of scope.
+class SYNC_EXPORT_PRIVATE ScopedCryptographer {
Nicolas Zea 2014/07/24 22:16:42 I find this naming a bit confusing. ScopedCryptogr
rlarocque 2014/07/24 22:23:13 I was trying to get across the idea that the Crypt
Nicolas Zea 2014/07/24 22:34:19 I see. Yeah, ScopedCryptographerRef seems better i
+ public:
+ ScopedCryptographer();
+ ~ScopedCryptographer();
+
+ bool Initialize(ScopedCryptographerImpl* impl);
+ bool IsValid() const;
+ Cryptographer* Get() const;
+
+ private:
+ scoped_ptr<ScopedCryptographerImpl> scoped_cryptographer_impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedCryptographer);
+};
+
+// An interface class used in the implementation of the ScopedCryptographer.
+//
+// We use this class to allow different implementations of
+// CryptographerProvider to implement InitScopedCryptographer in different
+// ways. The ScopedCryptographer itself must be stack-allocated, so it can't
+// vary depending on which kind of CryptographerProvider is used to intialize
+// it.
+class SYNC_EXPORT_PRIVATE ScopedCryptographerImpl {
+ public:
+ ScopedCryptographerImpl();
+ virtual ~ScopedCryptographerImpl();
+
+ virtual Cryptographer* Get() const = 0;
+};
+
+} // namespace syncer
+
+#endif // SYNC_ENGINE_CRYPTOGRAPHER_PROVIDER_H_
« no previous file with comments | « no previous file | sync/engine/cryptographer_provider.cc » ('j') | sync/engine/cryptographer_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698