1/* 2 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "StorageAreaImpl.h" 28 29#include "StorageAreaMap.h" 30#include <WebCore/Document.h> 31#include <WebCore/ExceptionCode.h> 32#include <WebCore/Frame.h> 33#include <WebCore/Page.h> 34#include <WebCore/SchemeRegistry.h> 35#include <WebCore/Settings.h> 36 37using namespace WebCore; 38 39namespace WebKit { 40 41static uint64_t generateStorageAreaID() 42{ 43 static uint64_t storageAreaID; 44 return ++storageAreaID; 45} 46 47PassRefPtr<StorageAreaImpl> StorageAreaImpl::create(PassRefPtr<StorageAreaMap> storageAreaMap) 48{ 49 return adoptRef(new StorageAreaImpl(storageAreaMap)); 50} 51 52StorageAreaImpl::StorageAreaImpl(PassRefPtr<StorageAreaMap> storageAreaMap) 53 : m_storageAreaID(generateStorageAreaID()) 54 , m_storageAreaMap(storageAreaMap) 55{ 56} 57 58StorageAreaImpl::~StorageAreaImpl() 59{ 60} 61 62unsigned StorageAreaImpl::length() 63{ 64 return m_storageAreaMap->length(); 65} 66 67String StorageAreaImpl::key(unsigned index) 68{ 69 return m_storageAreaMap->key(index); 70} 71 72String StorageAreaImpl::item(const String& key) 73{ 74 return m_storageAreaMap->item(key); 75} 76 77void StorageAreaImpl::setItem(Frame* sourceFrame, const String& key, const String& value, bool& quotaException) 78{ 79 ASSERT(!value.isNull()); 80 81 m_storageAreaMap->setItem(sourceFrame, this, key, value, quotaException); 82} 83 84void StorageAreaImpl::removeItem(Frame* sourceFrame, const String& key) 85{ 86 m_storageAreaMap->removeItem(sourceFrame, this, key); 87} 88 89void StorageAreaImpl::clear(Frame* sourceFrame) 90{ 91 m_storageAreaMap->clear(sourceFrame, this); 92} 93 94bool StorageAreaImpl::contains(const String& key) 95{ 96 return m_storageAreaMap->contains(key); 97} 98 99bool StorageAreaImpl::canAccessStorage(Frame* frame) 100{ 101 return frame && frame->page(); 102} 103 104StorageType StorageAreaImpl::storageType() const 105{ 106 return m_storageAreaMap->storageType(); 107} 108 109size_t StorageAreaImpl::memoryBytesUsedByCache() 110{ 111 return 0; 112} 113 114void StorageAreaImpl::incrementAccessCount() 115{ 116 // Storage access is handled in the UI process, so there's nothing to do here. 117} 118 119void StorageAreaImpl::decrementAccessCount() 120{ 121 // Storage access is handled in the UI process, so there's nothing to do here. 122} 123 124void StorageAreaImpl::closeDatabaseIfIdle() 125{ 126 // FIXME: Implement this. 127 ASSERT_NOT_REACHED(); 128} 129 130} // namespace WebKit 131