From 2ea07d0d9d8de515a987f889d5cdee876e00f125 Mon Sep 17 00:00:00 2001 From: zwtmichael Date: Thu, 29 Sep 2022 15:19:18 +0800 Subject: [PATCH] fix review issues Signed-off-by: zwtmichael --- .../common/include/runtime_context.h | 2 +- .../common/include/user_change_monitor.h | 2 +- .../common/src/notification_chain.cpp | 2 +- .../common/src/runtime_context_impl.cpp | 4 +-- .../common/src/runtime_context_impl.h | 3 +- .../common/src/user_change_monitor.cpp | 4 +-- .../include/kv_store_delegate_manager.h | 7 ++-- .../interfaces/include/store_types.h | 2 +- .../storage/src/sync_able_engine.cpp | 34 +++++++++---------- .../storage/src/sync_able_engine.h | 2 +- .../storage/src/sync_able_kvdb.cpp | 34 +++++++++---------- .../storage/src/sync_able_kvdb.h | 2 +- .../syncer/src/commit_history_sync.h | 2 +- .../distributeddb/syncer/src/device_manager.h | 2 +- .../src/single_ver_data_message_schedule.h | 2 +- .../syncer/src/single_ver_data_sync_utils.h | 3 +- .../src/single_ver_sync_state_machine.cpp | 2 +- .../src/single_ver_sync_task_context.cpp | 2 +- .../distributeddb/syncer/src/sync_engine.h | 1 - .../distributeddb/syncer/src/sync_operation.h | 4 +-- .../syncer/src/value_slice_sync.cpp | 6 ++-- 21 files changed, 61 insertions(+), 61 deletions(-) diff --git a/frameworks/libs/distributeddb/common/include/runtime_context.h b/frameworks/libs/distributeddb/common/include/runtime_context.h index dc291b983b0..e504950ba36 100644 --- a/frameworks/libs/distributeddb/common/include/runtime_context.h +++ b/frameworks/libs/distributeddb/common/include/runtime_context.h @@ -122,7 +122,7 @@ public: virtual bool IsSyncerNeedActive(const DBProperties &properties) const = 0; - virtual NotificationChain::Listener *RegisterUserChangedListerner(const UserChangedAction &action, + virtual NotificationChain::Listener *RegisterUserChangedListener(const UserChangedAction &action, EventType event) = 0; virtual int NotifyUserChanged() const = 0; diff --git a/frameworks/libs/distributeddb/common/include/user_change_monitor.h b/frameworks/libs/distributeddb/common/include/user_change_monitor.h index 1f2837c3a8d..6f55d9e18eb 100644 --- a/frameworks/libs/distributeddb/common/include/user_change_monitor.h +++ b/frameworks/libs/distributeddb/common/include/user_change_monitor.h @@ -38,7 +38,7 @@ public: void Stop(); // Register a user changed lister, it will be callback when user changed. - NotificationChain::Listener *RegisterUserChangedListerner(const UserChangedAction &action, EventType event, + NotificationChain::Listener *RegisterUserChangedListener(const UserChangedAction &action, EventType event, int &errCode); // Notify USER_CHANGE_EVENT. diff --git a/frameworks/libs/distributeddb/common/src/notification_chain.cpp b/frameworks/libs/distributeddb/common/src/notification_chain.cpp index 4b7daea5f42..237fcf9d38a 100644 --- a/frameworks/libs/distributeddb/common/src/notification_chain.cpp +++ b/frameworks/libs/distributeddb/common/src/notification_chain.cpp @@ -221,7 +221,7 @@ void NotificationChain::ListenerChain::ClearListeners() for (auto listener : tmpSet) { // Drop the ref 1 which increased in 'BackupListenerSet()', - // the origal 1 will be dropped when user call listener->Drop(); + // the original 1 will be dropped when user call listener->Drop(); listener->KillAndDecObjRef(listener); listener = nullptr; } diff --git a/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp b/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp index f9cba285a11..ed2510b2207 100644 --- a/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp +++ b/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp @@ -642,7 +642,7 @@ bool RuntimeContextImpl::IsSyncerNeedActive(const DBProperties &properties) cons return true; } -NotificationChain::Listener *RuntimeContextImpl::RegisterUserChangedListerner(const UserChangedAction &action, +NotificationChain::Listener *RuntimeContextImpl::RegisterUserChangedListener(const UserChangedAction &action, EventType event) { int errCode; @@ -656,7 +656,7 @@ NotificationChain::Listener *RuntimeContextImpl::RegisterUserChangedListerner(co return nullptr; } } - NotificationChain::Listener *listener = userChangeMonitor_->RegisterUserChangedListerner(action, event, errCode); + NotificationChain::Listener *listener = userChangeMonitor_->RegisterUserChangedListener(action, event, errCode); if ((listener == nullptr) || (errCode != E_OK)) { LOGE("Register user status changed listener failed, err = %d", errCode); return nullptr; diff --git a/frameworks/libs/distributeddb/common/src/runtime_context_impl.h b/frameworks/libs/distributeddb/common/src/runtime_context_impl.h index 5df535dd42c..7ee478543f1 100644 --- a/frameworks/libs/distributeddb/common/src/runtime_context_impl.h +++ b/frameworks/libs/distributeddb/common/src/runtime_context_impl.h @@ -25,7 +25,6 @@ #include "evloop/include/ievent_loop.h" #include "icommunicator_aggregator.h" #include "lock_status_observer.h" -#include "runtime_context.h" #include "task_pool.h" #include "time_tick_monitor.h" #include "user_change_monitor.h" @@ -112,7 +111,7 @@ public: bool IsSyncerNeedActive(const DBProperties &properties) const override; // Register a user changed lister, it will be callback when user change. - NotificationChain::Listener *RegisterUserChangedListerner(const UserChangedAction &action, + NotificationChain::Listener *RegisterUserChangedListener(const UserChangedAction &action, EventType event) override; // Notify TIME_CHANGE_EVENT. int NotifyUserChanged() const override; diff --git a/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp b/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp index 6f6166e19a7..c7d67e541c0 100644 --- a/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp +++ b/frameworks/libs/distributeddb/common/src/user_change_monitor.cpp @@ -59,7 +59,7 @@ void UserChangeMonitor::Stop() isStarted_ = false; } -NotificationChain::Listener *UserChangeMonitor::RegisterUserChangedListerner(const UserChangedAction &action, +NotificationChain::Listener *UserChangeMonitor::RegisterUserChangedListener(const UserChangedAction &action, EventType event, int &errCode) { std::shared_lock lockGuard(userChangeMonitorLock_); @@ -71,7 +71,7 @@ NotificationChain::Listener *UserChangeMonitor::RegisterUserChangedListerner(con errCode = -E_NOT_INIT; return nullptr; } - LOGI("[UserChangeMonitor] RegisterUserChangedListerner event=%d", event); + LOGI("[UserChangeMonitor] RegisterUserChangedListener event=%d", event); return userNotifier_->RegisterListener(event, action, nullptr, errCode); } diff --git a/frameworks/libs/distributeddb/interfaces/include/kv_store_delegate_manager.h b/frameworks/libs/distributeddb/interfaces/include/kv_store_delegate_manager.h index 3ea9fe14743..70f1cc6ec37 100644 --- a/frameworks/libs/distributeddb/interfaces/include/kv_store_delegate_manager.h +++ b/frameworks/libs/distributeddb/interfaces/include/kv_store_delegate_manager.h @@ -21,14 +21,15 @@ #include #include + +#include "auto_launch_export.h" +#include "iprocess_communicator.h" +#include "iprocess_system_api_adapter.h" #ifndef OMIT_MULTI_VER #include "kv_store_delegate.h" #endif #include "kv_store_nb_delegate.h" #include "store_types.h" -#include "iprocess_communicator.h" -#include "iprocess_system_api_adapter.h" -#include "auto_launch_export.h" namespace DistributedDB { class KvStoreDelegateManager final { diff --git a/frameworks/libs/distributeddb/interfaces/include/store_types.h b/frameworks/libs/distributeddb/interfaces/include/store_types.h index 6c48b9303e4..fdc8b0a8cbd 100644 --- a/frameworks/libs/distributeddb/interfaces/include/store_types.h +++ b/frameworks/libs/distributeddb/interfaces/include/store_types.h @@ -17,8 +17,8 @@ #define KV_STORE_TYPE_H #include -#include #include +#include #include "types_export.h" diff --git a/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp b/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp index 670aad89002..282e3e68865 100644 --- a/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp +++ b/frameworks/libs/distributeddb/storage/src/sync_able_engine.cpp @@ -31,14 +31,14 @@ SyncAbleEngine::SyncAbleEngine(ISyncInterface *store) isSyncModuleActiveCheck_(false), isSyncNeedActive_(true), store_(store), - userChangeListerner_(nullptr) + userChangeListener_(nullptr) {} SyncAbleEngine::~SyncAbleEngine() { - if (userChangeListerner_ != nullptr) { - userChangeListerner_->Drop(true); - userChangeListerner_ = nullptr; + if (userChangeListener_ != nullptr) { + userChangeListener_->Drop(true); + userChangeListener_ = nullptr; } } @@ -131,14 +131,14 @@ int SyncAbleEngine::StartSyncerWithNoLock(bool isCheckSyncActive, bool isNeedAct } bool isSyncDualTupleMode = store_->GetDbProperties().GetBoolProp(DBProperties::SYNC_DUAL_TUPLE_MODE, false); - if (isSyncDualTupleMode && isCheckSyncActive && !isNeedActive && (userChangeListerner_ == nullptr)) { + if (isSyncDualTupleMode && isCheckSyncActive && !isNeedActive && (userChangeListener_ == nullptr)) { // active to non_active - userChangeListerner_ = RuntimeContext::GetInstance()->RegisterUserChangedListerner( + userChangeListener_ = RuntimeContext::GetInstance()->RegisterUserChangedListener( std::bind(&SyncAbleEngine::ChangeUserListerner, this), UserChangeMonitor::USER_ACTIVE_TO_NON_ACTIVE_EVENT); - } else if (isSyncDualTupleMode && (userChangeListerner_ == nullptr)) { + } else if (isSyncDualTupleMode && (userChangeListener_ == nullptr)) { EventType event = isNeedActive ? UserChangeMonitor::USER_ACTIVE_EVENT : UserChangeMonitor::USER_NON_ACTIVE_EVENT; - userChangeListerner_ = RuntimeContext::GetInstance()->RegisterUserChangedListerner( + userChangeListener_ = RuntimeContext::GetInstance()->RegisterUserChangedListener( std::bind(&SyncAbleEngine::UserChangeHandle, this), event); } return errCode; @@ -159,9 +159,9 @@ void SyncAbleEngine::StopSyncerWithNoLock(bool isClosedOperation) started_ = false; } closed_ = isClosedOperation; - if (userChangeListerner_ != nullptr) { - userChangeListerner_->Drop(false); - userChangeListerner_ = nullptr; + if (userChangeListener_ != nullptr) { + userChangeListener_->Drop(false); + userChangeListener_ = nullptr; } } @@ -187,13 +187,13 @@ void SyncAbleEngine::UserChangeHandle() void SyncAbleEngine::ChangeUserListerner() { - // only active to non_active call, put into USER_NON_ACTIVE_EVENT listerner from USER_ACTIVE_TO_NON_ACTIVE_EVENT - if (userChangeListerner_ != nullptr) { - userChangeListerner_->Drop(false); - userChangeListerner_ = nullptr; + // only active to non_active call, put into USER_NON_ACTIVE_EVENT listener from USER_ACTIVE_TO_NON_ACTIVE_EVENT + if (userChangeListener_ != nullptr) { + userChangeListener_->Drop(false); + userChangeListener_ = nullptr; } - if (userChangeListerner_ == nullptr) { - userChangeListerner_ = RuntimeContext::GetInstance()->RegisterUserChangedListerner( + if (userChangeListener_ == nullptr) { + userChangeListener_ = RuntimeContext::GetInstance()->RegisterUserChangedListener( std::bind(&SyncAbleEngine::UserChangeHandle, this), UserChangeMonitor::USER_NON_ACTIVE_EVENT); } } diff --git a/frameworks/libs/distributeddb/storage/src/sync_able_engine.h b/frameworks/libs/distributeddb/storage/src/sync_able_engine.h index d7b949c7d14..609a55d4c9d 100644 --- a/frameworks/libs/distributeddb/storage/src/sync_able_engine.h +++ b/frameworks/libs/distributeddb/storage/src/sync_able_engine.h @@ -84,7 +84,7 @@ private: ISyncInterface *store_; mutable std::mutex syncerOperateLock_; - NotificationChain::Listener *userChangeListerner_; + NotificationChain::Listener *userChangeListener_; }; } // namespace DistributedDB #endif // SYNC_ABLE_ENGINE_H \ No newline at end of file diff --git a/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp b/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp index c4fbdb2af7e..fc55252d7d8 100644 --- a/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp +++ b/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.cpp @@ -31,7 +31,7 @@ SyncAbleKvDB::SyncAbleKvDB() isSyncModuleActiveCheck_(false), isSyncNeedActive_(true), notifyChain_(nullptr), - userChangeListerner_(nullptr) + userChangeListener_(nullptr) {} SyncAbleKvDB::~SyncAbleKvDB() @@ -41,9 +41,9 @@ SyncAbleKvDB::~SyncAbleKvDB() KillAndDecObjRef(notifyChain_); notifyChain_ = nullptr; } - if (userChangeListerner_ != nullptr) { - userChangeListerner_->Drop(true); - userChangeListerner_ = nullptr; + if (userChangeListener_ != nullptr) { + userChangeListener_->Drop(true); + userChangeListener_ = nullptr; } } @@ -180,14 +180,14 @@ int SyncAbleKvDB::StartSyncerWithNoLock(bool isCheckSyncActive, bool isNeedActiv } bool isSyncDualTupleMode = syncInterface->GetDbProperties().GetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, false); - if (isSyncDualTupleMode && isCheckSyncActive && !isNeedActive && (userChangeListerner_ == nullptr)) { + if (isSyncDualTupleMode && isCheckSyncActive && !isNeedActive && (userChangeListener_ == nullptr)) { // active to non_active - userChangeListerner_ = RuntimeContext::GetInstance()->RegisterUserChangedListerner( + userChangeListener_ = RuntimeContext::GetInstance()->RegisterUserChangedListener( std::bind(&SyncAbleKvDB::ChangeUserListerner, this), UserChangeMonitor::USER_ACTIVE_TO_NON_ACTIVE_EVENT); - } else if (isSyncDualTupleMode && (userChangeListerner_ == nullptr)) { + } else if (isSyncDualTupleMode && (userChangeListener_ == nullptr)) { EventType event = isNeedActive ? UserChangeMonitor::USER_ACTIVE_EVENT : UserChangeMonitor::USER_NON_ACTIVE_EVENT; - userChangeListerner_ = RuntimeContext::GetInstance()->RegisterUserChangedListerner( + userChangeListener_ = RuntimeContext::GetInstance()->RegisterUserChangedListener( std::bind(&SyncAbleKvDB::UserChangeHandle, this), event); } return errCode; @@ -208,9 +208,9 @@ void SyncAbleKvDB::StopSyncerWithNoLock(bool isClosedOperation) started_ = false; } closed_ = isClosedOperation; - if (userChangeListerner_ != nullptr) { - userChangeListerner_->Drop(false); - userChangeListerner_ = nullptr; + if (userChangeListener_ != nullptr) { + userChangeListener_->Drop(false); + userChangeListener_ = nullptr; } } @@ -241,13 +241,13 @@ void SyncAbleKvDB::UserChangeHandle() void SyncAbleKvDB::ChangeUserListerner() { - // only active to non_active call, put into USER_NON_ACTIVE_EVENT listerner from USER_ACTIVE_TO_NON_ACTIVE_EVENT - if (userChangeListerner_ != nullptr) { - userChangeListerner_->Drop(false); - userChangeListerner_ = nullptr; + // only active to non_active call, put into USER_NON_ACTIVE_EVENT listener from USER_ACTIVE_TO_NON_ACTIVE_EVENT + if (userChangeListener_ != nullptr) { + userChangeListener_->Drop(false); + userChangeListener_ = nullptr; } - if (userChangeListerner_ == nullptr) { - userChangeListerner_ = RuntimeContext::GetInstance()->RegisterUserChangedListerner( + if (userChangeListener_ == nullptr) { + userChangeListener_ = RuntimeContext::GetInstance()->RegisterUserChangedListener( std::bind(&SyncAbleKvDB::UserChangeHandle, this), UserChangeMonitor::USER_NON_ACTIVE_EVENT); } } diff --git a/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.h b/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.h index 133a242c604..56e1289a99f 100644 --- a/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.h +++ b/frameworks/libs/distributeddb/storage/src/sync_able_kvdb.h @@ -126,7 +126,7 @@ private: NotificationChain *notifyChain_; mutable std::mutex syncerOperateLock_; - NotificationChain::Listener *userChangeListerner_; + NotificationChain::Listener *userChangeListener_; static const EventType REMOTE_PUSH_FINISHED; }; diff --git a/frameworks/libs/distributeddb/syncer/src/commit_history_sync.h b/frameworks/libs/distributeddb/syncer/src/commit_history_sync.h index 5c7869fe5f3..644d68732a7 100644 --- a/frameworks/libs/distributeddb/syncer/src/commit_history_sync.h +++ b/frameworks/libs/distributeddb/syncer/src/commit_history_sync.h @@ -17,8 +17,8 @@ #define COMMIT_HISTORY_SYNC_H #ifndef OMIT_MULTI_VER -#include #include +#include #include "icommunicator.h" #include "multi_ver_kvdb_sync_interface.h" diff --git a/frameworks/libs/distributeddb/syncer/src/device_manager.h b/frameworks/libs/distributeddb/syncer/src/device_manager.h index 5b638b1e20d..d9cbfaae5e5 100644 --- a/frameworks/libs/distributeddb/syncer/src/device_manager.h +++ b/frameworks/libs/distributeddb/syncer/src/device_manager.h @@ -16,8 +16,8 @@ #ifndef DEVICE_MANAGER_H #define DEVICE_MANAGER_H -#include #include +#include #include "icommunicator.h" diff --git a/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.h b/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.h index bc9a0937e6b..f8335b9d9d0 100644 --- a/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.h +++ b/frameworks/libs/distributeddb/syncer/src/single_ver_data_message_schedule.h @@ -15,8 +15,8 @@ #ifndef SINGLE_VER_DATA_MESSAGE_SCHEDULE_H #define SINGLE_VER_DATA_MESSAGE_SCHEDULE_H -#include #include +#include #include #include diff --git a/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h b/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h index 8519bcf7fda..09ff9780c55 100644 --- a/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h +++ b/frameworks/libs/distributeddb/syncer/src/single_ver_data_sync_utils.h @@ -14,9 +14,10 @@ */ #ifndef SINGLE_VER_DATA_SYNC_UTIL_H #define SINGLE_VER_DATA_SYNC_UTIL_H + +#include "message.h" #include "single_ver_data_packet.h" #include "single_ver_sync_task_context.h" -#include "message.h" namespace DistributedDB { class SingleVerDataSyncUtils { public: diff --git a/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp b/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp index 64118156290..fc1c9b8617f 100644 --- a/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp +++ b/frameworks/libs/distributeddb/syncer/src/single_ver_sync_state_machine.cpp @@ -412,7 +412,7 @@ Event SingleVerSyncStateMachine::DoPassiveDataSyncWithSlidingWindow() } int errCode = dataSync_->SyncStart(SyncModeType::RESPONSE_PULL, context_); if (errCode != E_OK) { - LOGW("[SingleVerSyncStateMachine][DoPassiveDataSyncWithSlidingWindow] response pull send failed[%d]", errCode); + LOGE("[SingleVerSyncStateMachine][DoPassiveDataSyncWithSlidingWindow] response pull send failed[%d]", errCode); return RESPONSE_TASK_FINISHED_EVENT; } return Event::WAIT_ACK_EVENT; diff --git a/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp b/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp index e4daa17e994..ea6dae5b92d 100644 --- a/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp +++ b/frameworks/libs/distributeddb/syncer/src/single_ver_sync_task_context.cpp @@ -19,8 +19,8 @@ #include "db_common.h" #include "db_dfx_adapter.h" #include "db_errno.h" -#include "log_print.h" #include "isyncer.h" +#include "log_print.h" #include "single_ver_sync_state_machine.h" #include "single_ver_sync_target.h" #include "sync_types.h" diff --git a/frameworks/libs/distributeddb/syncer/src/sync_engine.h b/frameworks/libs/distributeddb/syncer/src/sync_engine.h index 178d4858665..a4fd7466477 100644 --- a/frameworks/libs/distributeddb/syncer/src/sync_engine.h +++ b/frameworks/libs/distributeddb/syncer/src/sync_engine.h @@ -29,7 +29,6 @@ #include "task_pool.h" namespace DistributedDB { -constexpr uint16_t NEW_SEND_TASK = 1; class SyncEngine : public ISyncEngine { public: diff --git a/frameworks/libs/distributeddb/syncer/src/sync_operation.h b/frameworks/libs/distributeddb/syncer/src/sync_operation.h index 040a2fcf0c5..bb4f02c9399 100644 --- a/frameworks/libs/distributeddb/syncer/src/sync_operation.h +++ b/frameworks/libs/distributeddb/syncer/src/sync_operation.h @@ -17,10 +17,10 @@ #define SYNC_OPERATION_H #include -#include -#include #include #include +#include +#include #include "ikvdb_sync_interface.h" #include "notification_chain.h" diff --git a/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp b/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp index 6b19fa333dc..d9490cecb64 100644 --- a/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp +++ b/frameworks/libs/distributeddb/syncer/src/value_slice_sync.cpp @@ -16,12 +16,12 @@ #ifndef OMIT_MULTI_VER #include "value_slice_sync.h" -#include "parcel.h" +#include "db_constant.h" #include "log_print.h" -#include "sync_types.h" #include "message_transform.h" +#include "parcel.h" #include "performance_analysis.h" -#include "db_constant.h" +#include "sync_types.h" namespace DistributedDB { const int ValueSliceSync::MAX_VALUE_NODE_SIZE = 100000; -- Gitee