summaryrefslogtreecommitdiffstats
path: root/sync/engine/directory_cryptographer_provider.h
blob: 36b1c0f90fdaa2e35de4d46c4edf7b4598107321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// 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_DIRECTORY_CRYPTOGRAPHER_PROVIDER_H_
#define SYNC_ENGINE_DIRECTORY_CRYPTOGRAPHER_PROVIDER_H_

#include "sync/engine/cryptographer_provider.h"

#include "sync/syncable/syncable_read_transaction.h"

namespace syncer {

namespace syncable {
class Directory;
}

// Provides access to the Directory's cryptographer through the
// CryptographerProvider interface.
class DirectoryCryptographerProvider : public CryptographerProvider {
 public:
  DirectoryCryptographerProvider(syncable::Directory* dir);
  virtual ~DirectoryCryptographerProvider();

  virtual bool InitScopedCryptographerRef(
      ScopedCryptographerRef* scoped) OVERRIDE;

 private:
  syncable::Directory* dir_;
};

// An implementation detail of the DirectoryCryptographerProvider.  Contains
// the ReadTransaction used to safely access the Cryptographer.
class ScopedDirectoryCryptographerInternal
    : public ScopedCryptographerInternal {
 public:
  ScopedDirectoryCryptographerInternal(syncable::Directory* dir);
  virtual ~ScopedDirectoryCryptographerInternal();

  virtual Cryptographer* Get() const OVERRIDE;

 private:
  syncable::Directory* dir_;
  syncable::ReadTransaction trans_;

  DISALLOW_COPY_AND_ASSIGN(ScopedDirectoryCryptographerInternal);
};

}  // namespace syncer

#endif  // SYNC_ENGINE_DIRECTORY_CRYPTOGRAPHER_PROVIDER_H_