OLD | NEW |
---|---|
(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 | |
tkent
2015/02/18 04:47:20
nit: We usually add no blank line between configh
horo
2015/02/18 04:56:58
Done.
| |
7 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h" | |
8 | |
9 #include "core/fetch/CachedMetadata.h" | |
10 #include "core/workers/WorkerGlobalScope.h" | |
11 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | |
12 | |
13 namespace blink { | |
14 | |
15 ServiceWorkerScriptCachedMetadataHandler::ServiceWorkerScriptCachedMetadataHandl er(WorkerGlobalScope* workerGlobalScope, const KURL& scriptURL, const Vector<cha r>* metaData) | |
16 : m_workerGlobalScope(workerGlobalScope) | |
17 , m_scriptURL(scriptURL) | |
18 { | |
19 if (metaData) | |
20 m_cachedMetadata = CachedMetadata::deserialize(metaData->data(), metaDat a->size()); | |
21 } | |
22 | |
23 ServiceWorkerScriptCachedMetadataHandler::~ServiceWorkerScriptCachedMetadataHand ler() | |
24 { | |
25 } | |
26 | |
27 void ServiceWorkerScriptCachedMetadataHandler::setCachedMetadata(unsigned dataTy peID, const char* data, size_t size, CacheType type) | |
28 { | |
29 if (type != SendToPlatform) | |
30 return; | |
31 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); | |
32 const Vector<char>& serializedData = m_cachedMetadata->serialize(); | |
33 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->setCachedMetadata (m_scriptURL, serializedData.data(), serializedData.size()); | |
34 } | |
35 | |
36 void ServiceWorkerScriptCachedMetadataHandler::clearCachedMetadata(CacheType typ e) | |
37 { | |
38 if (type != SendToPlatform) | |
39 return; | |
40 m_cachedMetadata = nullptr; | |
41 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->clearCachedMetada ta(m_scriptURL); | |
42 } | |
43 | |
44 CachedMetadata* ServiceWorkerScriptCachedMetadataHandler::cachedMetadata(unsigne d dataTypeID) const | |
45 { | |
46 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) | |
47 return nullptr; | |
48 return m_cachedMetadata.get(); | |
49 } | |
50 | |
51 String ServiceWorkerScriptCachedMetadataHandler::encoding() const | |
52 { | |
53 return ""; | |
tkent
2015/02/18 04:47:20
nit: Use emptyString() to avoid unnecessary String
horo
2015/02/18 04:56:58
Done.
| |
54 } | |
55 | |
56 } // namespace blink | |
OLD | NEW |