Merge "fix: use EINA_* booleans instread of TRUE/FALSE" into tizen
[platform/framework/web/wrt.git] / src / view / webkit / injected-bundle / page_global_context_container.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file page_global_context_container.h
18  * @author Tomasz Iwanek (t.iwanek@smasung.com)
19  * @brief Declares container for global context that holds its references
20  */
21 #ifndef PAGE_GLOBAL_CONTEXT_CONTAINER_H
22 #define PAGE_GLOBAL_CONTEXT_CONTAINER_H
23
24 #include <map>
25
26 #include <JavaScriptCore/JSContextRef.h>
27 #include <WKBundlePage.h>
28
29 /**
30  * @brief The PageGlobalContextContainer class
31  *
32  * Container for global contexts that increments reference for holded elements
33  */
34 class PageGlobalContextContainer
35 {
36 public:
37     typedef std::map<WKBundlePageRef, JSGlobalContextRef> PageGlobalContext;
38     typedef PageGlobalContext::iterator iterator;
39     typedef PageGlobalContext::const_iterator const_iterator;
40     typedef PageGlobalContext::value_type value_type;
41
42     PageGlobalContextContainer();
43     ~PageGlobalContextContainer();
44
45     PageGlobalContextContainer(const PageGlobalContextContainer&) = delete;
46     PageGlobalContextContainer& operator=(const PageGlobalContextContainer&) = delete;
47
48     void insertContextForPage(WKBundlePageRef page, JSGlobalContextRef context);
49     void removeContextForPage(WKBundlePageRef page);
50     /**
51      * @brief getContextForPage gets context for given page
52      * @param page wk page
53      * Page should be valid for container.
54      * If you don't know if page is present in container use find
55      *
56      * @return context
57      */
58     JSGlobalContextRef getContextForPage(WKBundlePageRef page) const;
59
60     const_iterator begin() const;
61     const_iterator find(WKBundlePageRef ref) const;
62     const_iterator end() const;
63 private:
64     PageGlobalContext m_map;
65 };
66
67 #endif // PAGE_GLOBAL_CONTEXT_CONTAINER_H