Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: Source/core/workers/WorkerScriptCachedMetadataHandler.cpp

Issue 929953002: CachedMetadata support for ServiceWorker script. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated kinuko's comment Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6
7 #include "core/workers/WorkerScriptCachedMetadataHandler.h"
8
9 #include "core/fetch/CachedMetadata.h"
10 #include "core/workers/WorkerGlobalScope.h"
11
12 namespace blink {
13
14 WorkerScriptCachedMetadataHandler::WorkerScriptCachedMetadataHandler(WorkerGloba lScope* workerGlobalScope, const KURL& scriptURL, const Vector<char>* metaData)
15 : m_workerGlobalScope(workerGlobalScope)
16 , m_scriptURL(scriptURL)
17 {
18 if (metaData)
19 m_cachedMetadata = CachedMetadata::deserialize(metaData->data(), metaDat a->size());
20 }
21
22 WorkerScriptCachedMetadataHandler::~WorkerScriptCachedMetadataHandler()
23 {
24 }
25
26 void WorkerScriptCachedMetadataHandler::setCachedMetadata(unsigned dataTypeID, c onst char* data, size_t size, CacheType type)
27 {
28 if (type != SendToPlatform)
29 return;
30 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size);
31 const Vector<char>& serializedData = m_cachedMetadata->serialize();
32 m_workerGlobalScope->setCachedMetadata(m_scriptURL, serializedData.data(), s erializedData.size());
33 }
34
35 void WorkerScriptCachedMetadataHandler::clearCachedMetadata(CacheType type)
36 {
37 if (type != SendToPlatform)
38 return;
39 m_cachedMetadata = nullptr;
40 m_workerGlobalScope->clearCachedMetadata(m_scriptURL);
41 }
42
43 CachedMetadata* WorkerScriptCachedMetadataHandler::cachedMetadata(unsigned dataT ypeID) const
44 {
45 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID)
46 return nullptr;
47 return m_cachedMetadata.get();
48 }
49
50 String WorkerScriptCachedMetadataHandler::encoding() const
51 {
52 return "";
53 }
54
55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698