Chromium Code Reviews| 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..8bec9586c72cff18236a230c150fd0f819ee544e |
| --- /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 ScopedCryptographerRef; |
| +class ScopedCryptographerImpl; |
| + |
| +// An interface for providing clients with a ScopedCryptographerRef. |
| +// |
| +// 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 InitScopedCryptographerRef(ScopedCryptographerRef* scoped) = 0; |
| +}; |
| + |
| +// A concrete class representing a cryptographer. |
|
Nicolas Zea
2014/07/25 20:03:30
nit: perhaps "representing a cryptographer" should
rlarocque
2014/07/25 20:18:17
Done.
|
| +// |
| +// Access to the cryptographer is lost when this class goes out of scope. |
| +class SYNC_EXPORT_PRIVATE ScopedCryptographerRef { |
| + public: |
| + ScopedCryptographerRef(); |
| + ~ScopedCryptographerRef(); |
| + |
| + bool Initialize(ScopedCryptographerImpl* impl); |
| + bool IsValid() const; |
| + Cryptographer* Get() const; |
| + |
| + private: |
| + scoped_ptr<ScopedCryptographerImpl> scoped_cryptographer_impl_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedCryptographerRef); |
| +}; |
| + |
| +// An interface class used in the implementation of the ScopedCryptographerRef. |
| +// |
| +// We use this class to allow different implementations of |
| +// CryptographerProvider to implement InitScopedCryptographer in different |
| +// ways. The ScopedCryptographerRef 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 { |
|
Nicolas Zea
2014/07/25 20:03:30
nit: this is the actual getter, not so much an imp
rlarocque
2014/07/25 20:18:17
Maybe Impl isn't the right suffix, given how we te
|
| + public: |
| + ScopedCryptographerImpl(); |
| + virtual ~ScopedCryptographerImpl(); |
| + |
| + virtual Cryptographer* Get() const = 0; |
| +}; |
| + |
| +} // namespace syncer |
| + |
| +#endif // SYNC_ENGINE_CRYPTOGRAPHER_PROVIDER_H_ |