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.cpp
18 * @author Tomasz Iwanek (t.iwanek@smasung.com)
19 * @brief Declares container for global context that holds its references
21 #include "page_global_context_container.h"
23 #include <dpl/foreach.h>
25 PageGlobalContextContainer::PageGlobalContextContainer()
29 PageGlobalContextContainer::~PageGlobalContextContainer()
33 JSGlobalContextRelease(iter->second);
37 void PageGlobalContextContainer::insertContextForPage(WKBundlePageRef page, JSGlobalContextRef context)
39 PageGlobalContext::iterator iter = m_map.find(page);
40 if(iter != m_map.end())
42 JSGlobalContextRelease(m_map[page]);
44 JSGlobalContextRetain(context);
45 m_map[page] = context;
48 void PageGlobalContextContainer::removeContextForPage(WKBundlePageRef page)
50 PageGlobalContext::iterator iter = m_map.find(page);
51 if(iter != m_map.end())
53 JSGlobalContextRelease(m_map[page]);
58 JSGlobalContextRef PageGlobalContextContainer::getContextForPage(WKBundlePageRef page) const
60 return m_map.find(page)->second;
63 PageGlobalContextContainer::const_iterator PageGlobalContextContainer::begin() const
67 PageGlobalContextContainer::const_iterator PageGlobalContextContainer::find(WKBundlePageRef ref) const
69 return m_map.find(ref);
71 PageGlobalContextContainer::const_iterator PageGlobalContextContainer::end() const