|
| 1 | +/* |
| 2 | + * Copyright (C) 2014 Igalia S.L. |
| 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 "NetworkCacheStorage.h" |
| 28 | + |
| 29 | +#if ENABLE(NETWORK_CACHE) |
| 30 | + |
| 31 | +#include "Logging.h" |
| 32 | +#include "NetworkCacheCoders.h" |
| 33 | +#include <WebCore/FileSystem.h> |
| 34 | +#include <WebCore/NotImplemented.h> |
| 35 | +#include <wtf/RunLoop.h> |
| 36 | + |
| 37 | +namespace WebKit { |
| 38 | + |
| 39 | +static const char* networkCacheSubdirectory = "WebKitCache"; |
| 40 | + |
| 41 | +NetworkCacheStorage::Data::Data() |
| 42 | + : m_data(nullptr) |
| 43 | + , m_size(0) |
| 44 | +{ |
| 45 | + notImplemented(); |
| 46 | +} |
| 47 | + |
| 48 | +NetworkCacheStorage::Data::Data(const uint8_t* data, size_t size) |
| 49 | + : m_data(data) |
| 50 | + , m_size(size) |
| 51 | +{ |
| 52 | + notImplemented(); |
| 53 | +} |
| 54 | + |
| 55 | +const uint8_t* NetworkCacheStorage::Data::data() const |
| 56 | +{ |
| 57 | + notImplemented(); |
| 58 | + return nullptr; |
| 59 | +} |
| 60 | + |
| 61 | +bool NetworkCacheStorage::Data::isNull() const |
| 62 | +{ |
| 63 | + notImplemented(); |
| 64 | + return true; |
| 65 | +} |
| 66 | + |
| 67 | +std::unique_ptr<NetworkCacheStorage> NetworkCacheStorage::open(const String& applicationCachePath) |
| 68 | +{ |
| 69 | + ASSERT(RunLoop::isMain()); |
| 70 | + String networkCachePath = WebCore::pathByAppendingComponent(applicationCachePath, networkCacheSubdirectory); |
| 71 | + if (!WebCore::makeAllDirectories(networkCachePath)) |
| 72 | + return nullptr; |
| 73 | + return std::unique_ptr<NetworkCacheStorage>(new NetworkCacheStorage(networkCachePath)); |
| 74 | +} |
| 75 | + |
| 76 | +NetworkCacheStorage::NetworkCacheStorage(const String& directoryPath) |
| 77 | + : m_directoryPath(directoryPath) |
| 78 | + , m_maximumSize(std::numeric_limits<size_t>::max()) |
| 79 | + , m_activeRetrieveOperationCount(0) |
| 80 | +{ |
| 81 | + initializeKeyFilter(); |
| 82 | +} |
| 83 | + |
| 84 | +void NetworkCacheStorage::initializeKeyFilter() |
| 85 | +{ |
| 86 | + ASSERT(RunLoop::isMain()); |
| 87 | + notImplemented(); |
| 88 | +} |
| 89 | + |
| 90 | +void NetworkCacheStorage::removeEntry(const NetworkCacheKey&) |
| 91 | +{ |
| 92 | + ASSERT(RunLoop::isMain()); |
| 93 | + notImplemented(); |
| 94 | +} |
| 95 | + |
| 96 | +void NetworkCacheStorage::dispatchRetrieveOperation(const RetrieveOperation&) |
| 97 | +{ |
| 98 | + ASSERT(RunLoop::isMain()); |
| 99 | + notImplemented(); |
| 100 | +} |
| 101 | + |
| 102 | +void NetworkCacheStorage::dispatchPendingRetrieveOperations() |
| 103 | +{ |
| 104 | + ASSERT(RunLoop::isMain()); |
| 105 | + notImplemented(); |
| 106 | +} |
| 107 | + |
| 108 | +void NetworkCacheStorage::retrieve(const NetworkCacheKey&, unsigned /* priority */, std::function<bool (std::unique_ptr<Entry>)> completionHandler) |
| 109 | +{ |
| 110 | + ASSERT(RunLoop::isMain()); |
| 111 | + notImplemented(); |
| 112 | + completionHandler(nullptr); |
| 113 | +} |
| 114 | + |
| 115 | +void NetworkCacheStorage::store(const NetworkCacheKey&, const Entry&, std::function<void (bool success)> completionHandler) |
| 116 | +{ |
| 117 | + ASSERT(RunLoop::isMain()); |
| 118 | + notImplemented(); |
| 119 | + completionHandler(false); |
| 120 | +} |
| 121 | + |
| 122 | +void NetworkCacheStorage::setMaximumSize(size_t size) |
| 123 | +{ |
| 124 | + ASSERT(RunLoop::isMain()); |
| 125 | + notImplemented(); |
| 126 | + m_maximumSize = size; |
| 127 | +} |
| 128 | + |
| 129 | +void NetworkCacheStorage::clear() |
| 130 | +{ |
| 131 | + ASSERT(RunLoop::isMain()); |
| 132 | + LOG(NetworkCacheStorage, "(NetworkProcess) clearing cache"); |
| 133 | + notImplemented(); |
| 134 | + m_keyFilter.clear(); |
| 135 | +} |
| 136 | + |
| 137 | +} // namespace WebKit |
| 138 | + |
| 139 | +#endif // ENABLE(NETWORK_CACHE) |
0 commit comments