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.
5 #include "sync/engine/directory_cryptographer_provider.h"
7 #include "sync/syncable/directory.h"
8 #include "sync/syncable/syncable_read_transaction.h"
12 DirectoryCryptographerProvider::DirectoryCryptographerProvider(
13 syncable::Directory* dir)
17 DirectoryCryptographerProvider::~DirectoryCryptographerProvider() {
20 bool DirectoryCryptographerProvider::InitScopedCryptographerRef(
21 ScopedCryptographerRef* scoped) {
22 scoped->Initialize(new ScopedDirectoryCryptographerInternal(dir_));
23 return scoped->IsValid();
26 ScopedDirectoryCryptographerInternal::ScopedDirectoryCryptographerInternal(
27 syncable::Directory* dir)
28 : dir_(dir), trans_(FROM_HERE, dir) {
31 ScopedDirectoryCryptographerInternal::~ScopedDirectoryCryptographerInternal() {
34 Cryptographer* ScopedDirectoryCryptographerInternal::Get() const {
35 return dir_->GetCryptographer(&trans_);