fix gbs/obs build failure
[framework/osp/web.git] / src / controls / FWebCtrl_WebManager.cpp
1 //\r
2 // Open Service Platform\r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
4 //\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
8 //\r
9 //     http://www.apache.org/licenses/LICENSE-2.0\r
10 //\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
16 //\r
17 \r
18 /**\r
19  * @file                FWebCtrl_WebManager.cpp\r
20  * @brief               The file contains the definition of _WebManager class.\r
21  *\r
22  * The file contains the definition of _WebManager class.\r
23  */\r
24 \r
25 #include <FBaseSysLog.h>\r
26 #include "FWebCtrl_WebImpl.h"\r
27 #include "FWebCtrl_WebManager.h"\r
28 \r
29 using namespace Tizen::Base;\r
30 using namespace Tizen::Base::Collection;\r
31 \r
32 namespace Tizen { namespace Web { namespace Controls\r
33 {\r
34 \r
35 _WebManager::_WebManager(void)\r
36         : __pWebList(null)\r
37         , __pCallbackList(null)\r
38 {\r
39 }\r
40 \r
41 _WebManager::~_WebManager(void)\r
42 {\r
43 }\r
44 \r
45 _WebManager*\r
46 _WebManager::GetInstance(void)\r
47 {\r
48         result r = E_SUCCESS;\r
49         static _WebManager* pWebMgr = null;\r
50 \r
51         if (pWebMgr == null)\r
52         {\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
55 \r
56                 r = pWebMgr->Construct();\r
57                 SysTryCatch(NID_WEB_CTRL, !IsFailed(r), , r, "[%s] _WebManager construction failed.", GetErrorMessage(r));\r
58         }\r
59 \r
60         return pWebMgr;\r
61 \r
62 CATCH:\r
63         delete pWebMgr;\r
64         pWebMgr = null;\r
65 \r
66         return null;\r
67 }\r
68 \r
69 result\r
70 _WebManager::Construct(void)\r
71 {\r
72         result r = E_SUCCESS;\r
73 \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
78 \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
83 \r
84         __pWebList = std::move(pWebList);\r
85         __pCallbackList = std::move(pCallbackList);\r
86 \r
87         return E_SUCCESS;\r
88 }\r
89 \r
90 result\r
91 _WebManager::AddWeb(int webAdress)\r
92 {\r
93         result r = E_SUCCESS;\r
94 \r
95         r = __pWebList->Add(webAdress);\r
96         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));\r
97 \r
98         return E_SUCCESS;\r
99 }\r
100 \r
101 result\r
102 _WebManager::RemoveWeb(int webAdress)\r
103 {\r
104         result r = E_SUCCESS;\r
105 \r
106         r = __pWebList->Remove(webAdress);\r
107         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));\r
108 \r
109         r = __pCallbackList->Remove(webAdress);\r
110         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));\r
111 \r
112         return E_SUCCESS;\r
113 }\r
114 \r
115 bool\r
116 _WebManager::IsValidWeb(int webAdress) const\r
117 {\r
118         return __pWebList->Contains(webAdress);\r
119 }\r
120 \r
121 \r
122 result\r
123 _WebManager::AddCallback(int callerAdress, int callbackAdress)\r
124 {\r
125         result r = E_SUCCESS;\r
126 \r
127         r = __pCallbackList->Add(callerAdress, callbackAdress);\r
128         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));\r
129 \r
130         return E_SUCCESS;\r
131 }\r
132 \r
133 result\r
134 _WebManager::RemoveCallback(int callerAdress, int callbackAdress)\r
135 {\r
136         result r = E_SUCCESS;\r
137 \r
138         r = __pCallbackList->Remove(callerAdress, callbackAdress);\r
139         SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));\r
140 \r
141         return E_SUCCESS;\r
142 }\r
143 \r
144 bool\r
145 _WebManager::IsValidCallback(int callerAdress, int callbackAdress) const\r
146 {\r
147         bool ret = true;\r
148 \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
151 \r
152         return ret;\r
153 }\r
154 \r
155 } } }\r