Fix import error in mac_platform_backend.py
[chromium-blink-merge.git] / sync / internal_api / public / base_transaction.h
blob2f4fa3c91b103ebf24a8c020dfdb05f7c76e1b21
1 // Copyright 2012 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 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_TRANSACTION_H_
6 #define SYNC_INTERNAL_API_PUBLIC_BASE_TRANSACTION_H_
8 #include "sync/base/sync_export.h"
9 #include "sync/internal_api/public/base/model_type.h"
10 #include "sync/internal_api/public/user_share.h"
11 #include "sync/util/cryptographer.h"
13 namespace syncer {
15 namespace syncable {
16 class BaseTransaction;
17 class Directory;
20 // Sync API's BaseTransaction, ReadTransaction, and WriteTransaction allow for
21 // batching of several read and/or write operations. The read and write
22 // operations are performed by creating ReadNode and WriteNode instances using
23 // the transaction. These transaction classes wrap identically named classes in
24 // syncable, and are used in a similar way. Unlike syncable::BaseTransaction,
25 // whose construction requires an explicit syncable::Directory, a sync
26 // API BaseTransaction is created from a UserShare object.
27 class SYNC_EXPORT BaseTransaction {
28 public:
29 // Provide access to the underlying syncable objects from BaseNode.
30 virtual syncable::BaseTransaction* GetWrappedTrans() const = 0;
31 Cryptographer* GetCryptographer() const;
32 ModelTypeSet GetEncryptedTypes() const;
34 syncable::Directory* GetDirectory() const {
35 if (!user_share_) {
36 return NULL;
37 } else {
38 return user_share_->directory.get();
42 UserShare* GetUserShare() const {
43 return user_share_;
46 protected:
47 explicit BaseTransaction(UserShare* share);
48 virtual ~BaseTransaction();
50 BaseTransaction() : user_share_(NULL) { }
52 private:
53 UserShare* user_share_;
55 DISALLOW_COPY_AND_ASSIGN(BaseTransaction);
58 } // namespace syncer
60 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_TRANSACTION_H_