2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
21 #ifndef PAGE_GLOBAL_CONTEXT_CONTAINER_H
22 #define PAGE_GLOBAL_CONTEXT_CONTAINER_H
26 #include <JavaScriptCore/JSContextRef.h>
27 #include <WKBundlePage.h>
30 * @brief The PageGlobalContextContainer class
32 * Container for global contexts that increments reference for holded elements
34 class PageGlobalContextContainer
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;
42 PageGlobalContextContainer();
43 ~PageGlobalContextContainer();
45 PageGlobalContextContainer(const PageGlobalContextContainer&) = delete;
46 PageGlobalContextContainer& operator=(const PageGlobalContextContainer&) = delete;
48 void insertContextForPage(WKBundlePageRef page, JSGlobalContextRef context);
49 void removeContextForPage(WKBundlePageRef page);
51 * @brief getContextForPage gets context for given page
53 * Page should be valid for container.
54 * If you don't know if page is present in container use find
58 JSGlobalContextRef getContextForPage(WKBundlePageRef page) const;
60 const_iterator begin() const;
61 const_iterator find(WKBundlePageRef ref) const;
62 const_iterator end() const;
64 PageGlobalContext m_map;
67 #endif // PAGE_GLOBAL_CONTEXT_CONTAINER_H