1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "clouddisk_rdb_transaction.h"
17 #include "utils_log.h"
18 
19 namespace OHOS {
20 namespace FileManagement {
21 namespace CloudDisk {
22 using namespace std;
23 
24 constexpr int32_t E_HAS_DB_ERROR = -222;
25 constexpr int32_t E_OK = 0;
26 
27 constexpr int RDB_TRANSACTION_WAIT_MS = 1000;
28 constexpr int32_t MAX_TRY_TIMES = 5;
29 constexpr int32_t TRANSACTION_WAIT_INTERVAL = 50; // in milliseconds.
30 
TransactionOperations(const shared_ptr<OHOS::NativeRdb::RdbStore> & rdbStore)31 TransactionOperations::TransactionOperations(
32     const shared_ptr<OHOS::NativeRdb::RdbStore> &rdbStore) : rdbStore_(rdbStore) {}
33 
~TransactionOperations()34 TransactionOperations::~TransactionOperations()
35 {
36     if (isStart && !isFinish) {
37         LOGI("TransactionOperations::RollBack");
38         TransactionRollback();
39     }
40 }
41 
Start(NativeRdb::Transaction::TransactionType type)42 std::pair<int32_t, std::shared_ptr<NativeRdb::Transaction>> TransactionOperations::Start(
43     NativeRdb::Transaction::TransactionType type)
44 {
45     return make_pair(E_OK, nullptr);
46 }
47 
Finish()48 void TransactionOperations::Finish()
49 {
50 }
51 
BeginTransaction(NativeRdb::Transaction::TransactionType type)52 int32_t TransactionOperations::BeginTransaction(
53     NativeRdb::Transaction::TransactionType type)
54 {
55     return E_OK;
56 }
57 
TransactionCommit()58 int32_t TransactionOperations::TransactionCommit()
59 {
60     return E_OK;
61 }
62 
TransactionRollback()63 int32_t TransactionOperations::TransactionRollback()
64 {
65     return E_OK;
66 }
67 } // namespace CloudDisk
68 } // namespace FileManagement
69 } // namespace OHOS