OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SYNC_ENGINE_CRYPTOGRAPHER_PROVIDER_H_ | |
6 #define SYNC_ENGINE_CRYPTOGRAPHER_PROVIDER_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "sync/base/sync_export.h" | |
10 | |
11 namespace syncer { | |
12 | |
13 class Cryptographer; | |
14 class ScopedCryptographer; | |
15 class ScopedCryptographerImpl; | |
16 | |
17 // An interface for providing clients with a ScopedCryptographer. | |
18 // | |
19 // Used to expose the syncable::Directory's cryptographer to clients that | |
20 // would otherwise not have access to the Directory. | |
21 class SYNC_EXPORT_PRIVATE CryptographerProvider { | |
22 public: | |
23 CryptographerProvider(); | |
24 virtual ~CryptographerProvider(); | |
25 | |
26 virtual bool InitScopedCryptographer(ScopedCryptographer* scoped) = 0; | |
27 }; | |
28 | |
29 // A concrete class representing a cryptographer. | |
30 // | |
31 // Access to the cryptographer is lost when this class goes out of scope. | |
32 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
| |
33 public: | |
34 ScopedCryptographer(); | |
35 ~ScopedCryptographer(); | |
36 | |
37 bool Initialize(ScopedCryptographerImpl* impl); | |
38 bool IsValid() const; | |
39 Cryptographer* Get() const; | |
40 | |
41 private: | |
42 scoped_ptr<ScopedCryptographerImpl> scoped_cryptographer_impl_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(ScopedCryptographer); | |
45 }; | |
46 | |
47 // An interface class used in the implementation of the ScopedCryptographer. | |
48 // | |
49 // We use this class to allow different implementations of | |
50 // CryptographerProvider to implement InitScopedCryptographer in different | |
51 // ways. The ScopedCryptographer itself must be stack-allocated, so it can't | |
52 // vary depending on which kind of CryptographerProvider is used to intialize | |
53 // it. | |
54 class SYNC_EXPORT_PRIVATE ScopedCryptographerImpl { | |
55 public: | |
56 ScopedCryptographerImpl(); | |
57 virtual ~ScopedCryptographerImpl(); | |
58 | |
59 virtual Cryptographer* Get() const = 0; | |
60 }; | |
61 | |
62 } // namespace syncer | |
63 | |
64 #endif // SYNC_ENGINE_CRYPTOGRAPHER_PROVIDER_H_ | |
OLD | NEW |