Roll src/third_party/WebKit 96fb88b:6bbd108 (svn 201045:201047)
[chromium-blink-merge.git] / sync / internal_api / public / read_transaction.h
blobbdb92cbeb33f218fd4b99b5fcea936af75084521
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_READ_TRANSACTION_H_
6 #define SYNC_INTERNAL_API_PUBLIC_READ_TRANSACTION_H_
8 #include "base/compiler_specific.h"
9 #include "sync/api/attachments/attachment_id.h"
10 #include "sync/base/sync_export.h"
11 #include "sync/internal_api/public/base_transaction.h"
13 namespace tracked_objects {
14 class Location;
15 } // namespace tracked_objects
17 namespace sync_pb {
18 class DataTypeContext;
21 namespace syncer {
23 struct UserShare;
25 // Sync API's ReadTransaction is a read-only BaseTransaction. It wraps
26 // a syncable::ReadTransaction.
27 class SYNC_EXPORT ReadTransaction : public BaseTransaction {
28 public:
29 // Start a new read-only transaction on the specified repository.
30 ReadTransaction(const tracked_objects::Location& from_here,
31 UserShare* share);
33 // Resume the middle of a transaction. Will not close transaction.
34 ReadTransaction(UserShare* share, syncable::BaseTransaction* trans);
36 ~ReadTransaction() override;
38 // BaseTransaction override.
39 syncable::BaseTransaction* GetWrappedTrans() const override;
41 // Return |transaction_version| of |type| stored in sync directory's
42 // persisted info.
43 int64 GetModelVersion(ModelType type) const;
45 // Fills |context| with the datatype context associated with |type|.
46 void GetDataTypeContext(ModelType type,
47 sync_pb::DataTypeContext* context) const;
49 // Clear |ids| and fill it with the ids of attachments that need to be
50 // uploaded to the sync server.
51 void GetAttachmentIdsToUpload(ModelType type, AttachmentIdList* ids) const;
53 // Return the current (opaque) store birthday.
54 std::string GetStoreBirthday() const;
56 private:
57 void* operator new(size_t size); // Transaction is meant for stack use only.
59 // The underlying syncable object which this class wraps.
60 syncable::BaseTransaction* transaction_;
61 bool close_transaction_;
63 DISALLOW_COPY_AND_ASSIGN(ReadTransaction);
66 } // namespace syncer
68 #endif // SYNC_INTERNAL_API_PUBLIC_READ_TRANSACTION_H_