2 // Open Service Platform
\r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
\r
5 // Licensed under the Apache License, Version 2.0 (the License);
\r
6 // you may not use this file except in compliance with the License.
\r
7 // You may obtain a copy of the License at
\r
9 // http://www.apache.org/licenses/LICENSE-2.0
\r
11 // Unless required by applicable law or agreed to in writing, software
\r
12 // distributed under the License is distributed on an "AS IS" BASIS,
\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 // See the License for the specific language governing permissions and
\r
15 // limitations under the License.
\r
19 * @file FWebCtrl_WebManager.cpp
\r
20 * @brief The file contains the definition of _WebManager class.
\r
22 * The file contains the definition of _WebManager class.
\r
25 #include <FBaseSysLog.h>
\r
26 #include "FWebCtrl_WebImpl.h"
\r
27 #include "FWebCtrl_WebManager.h"
\r
29 using namespace Tizen::Base;
\r
30 using namespace Tizen::Base::Collection;
\r
32 namespace Tizen { namespace Web { namespace Controls
\r
35 _WebManager::_WebManager(void)
\r
37 , __pCallbackList(null)
\r
41 _WebManager::~_WebManager(void)
\r
46 _WebManager::GetInstance(void)
\r
48 result r = E_SUCCESS;
\r
49 static _WebManager* pWebMgr = null;
\r
51 if (pWebMgr == null)
\r
53 pWebMgr = new (std::nothrow) _WebManager();
\r
54 SysTryReturn(NID_WEB_CTRL, pWebMgr != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] _WebManager allocation failed.");
\r
56 r = pWebMgr->Construct();
\r
57 SysTryCatch(NID_WEB_CTRL, !IsFailed(r), , r, "[%s] _WebManager construction failed.", GetErrorMessage(r));
\r
70 _WebManager::Construct(void)
\r
72 result r = E_SUCCESS;
\r
74 std::unique_ptr<ArrayListT< int> > pWebList(new (std::nothrow) ArrayListT< int >());
\r
75 SysTryReturnResult(NID_WEB_CTRL, pWebList.get(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
\r
76 r = pWebList->Construct();
\r
77 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
\r
79 std::unique_ptr<MultiHashMapT< int, int > > pCallbackList(new (std::nothrow) MultiHashMapT< int, int >());
\r
80 SysTryReturnResult(NID_WEB_CTRL, pCallbackList.get(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
\r
81 r = pCallbackList->Construct();
\r
82 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
\r
84 __pWebList = std::move(pWebList);
\r
85 __pCallbackList = std::move(pCallbackList);
\r
91 _WebManager::AddWeb(int webAdress)
\r
93 result r = E_SUCCESS;
\r
95 r = __pWebList->Add(webAdress);
\r
96 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
\r
102 _WebManager::RemoveWeb(int webAdress)
\r
104 result r = E_SUCCESS;
\r
106 r = __pWebList->Remove(webAdress);
\r
107 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
\r
109 r = __pCallbackList->Remove(webAdress);
\r
110 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
\r
116 _WebManager::IsValidWeb(int webAdress) const
\r
118 return __pWebList->Contains(webAdress);
\r
123 _WebManager::AddCallback(int callerAdress, int callbackAdress)
\r
125 result r = E_SUCCESS;
\r
127 r = __pCallbackList->Add(callerAdress, callbackAdress);
\r
128 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
\r
134 _WebManager::RemoveCallback(int callerAdress, int callbackAdress)
\r
136 result r = E_SUCCESS;
\r
138 r = __pCallbackList->Remove(callerAdress, callbackAdress);
\r
139 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
\r
145 _WebManager::IsValidCallback(int callerAdress, int callbackAdress) const
\r
149 result r = __pCallbackList->Contains(callerAdress, callbackAdress, ret);
\r
150 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
\r