Index: Source/core/workers/WorkerScriptCachedMetadataHandler.cpp |
diff --git a/Source/core/workers/WorkerScriptCachedMetadataHandler.cpp b/Source/core/workers/WorkerScriptCachedMetadataHandler.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7c445d8f7235fdcbc6744a99e793a636581de50b |
--- /dev/null |
+++ b/Source/core/workers/WorkerScriptCachedMetadataHandler.cpp |
@@ -0,0 +1,55 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+ |
+#include "core/workers/WorkerScriptCachedMetadataHandler.h" |
+ |
+#include "core/fetch/CachedMetadata.h" |
+#include "core/workers/WorkerGlobalScope.h" |
+ |
+namespace blink { |
+ |
+WorkerScriptCachedMetadataHandler::WorkerScriptCachedMetadataHandler(WorkerGlobalScope* workerGlobalScope, const KURL& scriptURL, const Vector<char>* metaData) |
+ : m_workerGlobalScope(workerGlobalScope) |
+ , m_scriptURL(scriptURL) |
+{ |
+ if (metaData) |
+ m_cachedMetadata = CachedMetadata::deserialize(metaData->data(), metaData->size()); |
+} |
+ |
+WorkerScriptCachedMetadataHandler::~WorkerScriptCachedMetadataHandler() |
+{ |
+} |
+ |
+void WorkerScriptCachedMetadataHandler::setCachedMetadata(unsigned dataTypeID, const char* data, size_t size, CacheType type) |
+{ |
+ if (type != SendToPlatform) |
+ return; |
+ m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); |
+ const Vector<char>& serializedData = m_cachedMetadata->serialize(); |
+ m_workerGlobalScope->setCachedMetadata(m_scriptURL, serializedData.data(), serializedData.size()); |
+} |
+ |
+void WorkerScriptCachedMetadataHandler::clearCachedMetadata(CacheType type) |
+{ |
+ if (type != SendToPlatform) |
+ return; |
+ m_cachedMetadata = nullptr; |
+ m_workerGlobalScope->clearCachedMetadata(m_scriptURL); |
+} |
+ |
+CachedMetadata* WorkerScriptCachedMetadataHandler::cachedMetadata(unsigned dataTypeID) const |
+{ |
+ if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) |
+ return nullptr; |
+ return m_cachedMetadata.get(); |
+} |
+ |
+String WorkerScriptCachedMetadataHandler::encoding() const |
+{ |
+ return ""; |
+} |
+ |
+} // namespace blink |