X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fapp%2FFApp_DataControlManager.cpp;h=25d3bd9a998c985cbd5f9efdbea281d2265e11c1;hb=HEAD;hp=02a33d8132b748075642e5e0bd94eab34564139a;hpb=488d573fa21c7b352a912f040f9b20593ab1556d;p=platform%2Fframework%2Fnative%2Fappfw.git diff --git a/src/app/FApp_DataControlManager.cpp b/src/app/FApp_DataControlManager.cpp index 02a33d8..25d3bd9 100644 --- a/src/app/FApp_DataControlManager.cpp +++ b/src/app/FApp_DataControlManager.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,7 @@ using namespace std; using namespace Tizen::Base; using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; using namespace Tizen::App::Package; namespace Tizen { namespace App @@ -50,12 +52,27 @@ _DataControlManager::_DataControlManager(void) , __pProviderList(null) , __uniqueId(-1) { - __pDataControlRequestList = new (std::nothrow) HashMap(SingleObjectDeleter); - SysTryReturnVoidResult(NID_APP, __pDataControlRequestList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); - __pDataControlRequestList->Construct(); +} + +result +_DataControlManager::Construct(void) +{ + unique_ptr< HashMap > pDataControlRequestList(new (std::nothrow) HashMap(SingleObjectDeleter)); + SysTryReturnResult(NID_APP, pDataControlRequestList != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = pDataControlRequestList->Construct(); + SysTryReturnResult(NID_APP, !IsFailed(r), r, "Propagating to caller..."); - __pProviderList = new (std::nothrow) LinkedList(SingleObjectDeleter); - SysTryReturnVoidResult(NID_APP, __pProviderList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + unique_ptr< LinkedList > pProviderList(new (std::nothrow) LinkedList(SingleObjectDeleter)); + SysTryReturnResult(NID_APP, pProviderList != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + r = __mutex.Create(); + SysTryReturnResult(NID_APP, !IsFailed(r), r, "Mutex initialization failed."); + + __pDataControlRequestList = pDataControlRequestList.release(); + __pProviderList = pProviderList.release(); + + return E_SUCCESS; } _DataControlManager::~_DataControlManager(void) @@ -70,10 +87,16 @@ _DataControlManager::InitSingleton(void) _DataControlManager* pInst = new (std::nothrow) _DataControlManager(); SysTryReturnVoidResult(NID_APP, pInst != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + result r = pInst->Construct(); + SysTryCatch(NID_IO, !IsFailed(r), , r, "[%s] Propagating to caller...", GetErrorMessage(r)); + __pDataControlManagerInstance = pInst; - + std::atexit(DestroySingleton); return; + +CATCH: + delete pInst; } void @@ -105,6 +128,8 @@ _DataControlManager::GetInstance(void) int _DataControlManager::GetRequestCount(void) const { + MutexGuard lock(__mutex); + return __pDataControlRequestList->GetCount(); } @@ -112,6 +137,8 @@ result _DataControlManager::AddRequestInfo(Integer* pReqId, _DataControlRequestInfo* pReqInfo) { //SysLog(NID_APP, "DataControl request list count: %d", __pDataControlRequestList->GetCount()); + MutexGuard lock(__mutex); + return __pDataControlRequestList->Add(pReqId, pReqInfo); } @@ -120,6 +147,8 @@ _DataControlManager::GetRequestInfo(Integer& reqId) { result r = E_SUCCESS; + MutexGuard lock(__mutex); + Object* pObj = __pDataControlRequestList->GetValue(reqId); SysTryReturn(NID_APP, pObj != null, null, GetLastResult(), "[%s] Propagating to caller...", GetErrorMessage(GetLastResult())); @@ -132,12 +161,16 @@ _DataControlManager::GetRequestInfo(Integer& reqId) void _DataControlManager::RemoveRequestInfo(Integer& reqId) { + MutexGuard lock(__mutex); + __pDataControlRequestList->Remove(reqId); } void _DataControlManager::RemoveAllRequests(void) { + MutexGuard lock(__mutex); + __pDataControlRequestList->RemoveAll(); }