summaryrefslogtreecommitdiff
path: root/chromium/content/renderer/cache_storage/webserviceworkercachestorage_impl.cc
blob: be2467e14b02570d426c0d9d0be84e77854fb834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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 "content/renderer/cache_storage/webserviceworkercachestorage_impl.h"

#include <memory>
#include <utility>

#include "content/child/thread_safe_sender.h"
#include "content/renderer/cache_storage/cache_storage_dispatcher.h"
#include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerCache.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponse.h"

using base::TimeTicks;

namespace content {

WebServiceWorkerCacheStorageImpl::WebServiceWorkerCacheStorageImpl(
    ThreadSafeSender* thread_safe_sender,
    const url::Origin& origin)
    : thread_safe_sender_(thread_safe_sender), origin_(origin) {}

WebServiceWorkerCacheStorageImpl::~WebServiceWorkerCacheStorageImpl() {
}

void WebServiceWorkerCacheStorageImpl::DispatchHas(
    std::unique_ptr<CacheStorageCallbacks> callbacks,
    const blink::WebString& cacheName) {
  GetDispatcher()->dispatchHas(std::move(callbacks), origin_, cacheName);
}

void WebServiceWorkerCacheStorageImpl::DispatchOpen(
    std::unique_ptr<CacheStorageWithCacheCallbacks> callbacks,
    const blink::WebString& cacheName) {
  GetDispatcher()->dispatchOpen(std::move(callbacks), origin_, cacheName);
}

void WebServiceWorkerCacheStorageImpl::DispatchDelete(
    std::unique_ptr<CacheStorageCallbacks> callbacks,
    const blink::WebString& cacheName) {
  GetDispatcher()->dispatchDelete(std::move(callbacks), origin_, cacheName);
}

void WebServiceWorkerCacheStorageImpl::DispatchKeys(
    std::unique_ptr<CacheStorageKeysCallbacks> callbacks) {
  GetDispatcher()->dispatchKeys(std::move(callbacks), origin_);
}

void WebServiceWorkerCacheStorageImpl::DispatchMatch(
    std::unique_ptr<CacheStorageMatchCallbacks> callbacks,
    const blink::WebServiceWorkerRequest& request,
    const blink::WebServiceWorkerCache::QueryParams& query_params) {
  GetDispatcher()->dispatchMatch(std::move(callbacks), origin_, request,
                                 query_params);
}

CacheStorageDispatcher* WebServiceWorkerCacheStorageImpl::GetDispatcher()
    const {
  return CacheStorageDispatcher::ThreadSpecificInstance(
      thread_safe_sender_.get());
}

}  // namespace content