2 // Tizen Web Device API
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #ifndef _TIZEN_COMMON_GLOBALCONTEXTMANAGER_
19 #define _TIZEN_COMMON_GLOBALCONTEXTMANAGER_
21 #include <JavaScriptCore/JavaScript.h>
29 * @brief Manage and tracking global context handle
31 class GlobalContextManager{
34 * @breif Gets global context from local context
36 * @param ctx local context
37 * @return The global context reference or NULL if function has failed
39 JSContextRef getGlobalContext(JSContextRef ctx);
42 * @breif Add global context in manager
44 * @param ctx The global context to add
46 void addGlobalContext(JSContextRef ctx);
49 * @breif Remove global context in manager
51 * @param ctx The global context to remove
53 void removeGlobalContext(JSContextRef ctx);
56 * @breif Check the validation of global context
58 * @param ctx The global context to check
59 * @return true : the global context is alive, false : the global context was released
61 bool isAliveGlobalContext(JSContextRef ctx);
64 * @breif Gets singletone handle
66 * @return GlobalContextManager handle
68 static GlobalContextManager* getInstance();
71 GlobalContextManager();
72 typedef std::map<JSObjectRef, JSContextRef> ContextMapT;
73 std::map<JSObjectRef, JSContextRef> mContexts;
78 #endif //_TIZEN_COMMON_GLOBALCONTEXTMANAGER_