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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.cpp

Issue 929953002: CachedMetadata support for ServiceWorker script. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated tkent'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 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h"
7
8 #include "core/fetch/CachedMetadata.h"
9 #include "core/workers/WorkerGlobalScope.h"
10 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
11
12 namespace blink {
13
14 ServiceWorkerScriptCachedMetadataHandler::ServiceWorkerScriptCachedMetadataHandl er(WorkerGlobalScope* workerGlobalScope, const KURL& scriptURL, const Vector<cha r>* 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 ServiceWorkerScriptCachedMetadataHandler::~ServiceWorkerScriptCachedMetadataHand ler()
23 {
24 }
25
26 void ServiceWorkerScriptCachedMetadataHandler::setCachedMetadata(unsigned dataTy peID, const 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 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->setCachedMetadata (m_scriptURL, serializedData.data(), serializedData.size());
33 }
34
35 void ServiceWorkerScriptCachedMetadataHandler::clearCachedMetadata(CacheType typ e)
36 {
37 if (type != SendToPlatform)
38 return;
39 m_cachedMetadata = nullptr;
40 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->clearCachedMetada ta(m_scriptURL);
41 }
42
43 CachedMetadata* ServiceWorkerScriptCachedMetadataHandler::cachedMetadata(unsigne d dataTypeID) const
44 {
45 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID)
46 return nullptr;
47 return m_cachedMetadata.get();
48 }
49
50 String ServiceWorkerScriptCachedMetadataHandler::encoding() const
51 {
52 return emptyString();
53 }
54
55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698