blob: 541b05778cb80b1fc928f42fdbd8032180143737 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright 2014 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.
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_RESPONSE_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_RESPONSE_H_
#include "base/time/time.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_error_type.mojom-shared.h"
#include "third_party/blink/public/platform/web_common.h"
#include "third_party/blink/public/platform/web_private_ptr.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_vector.h"
#if INSIDE_BLINK
#include "third_party/blink/renderer/platform/wtf/forward.h" // nogncheck
#include "third_party/blink/renderer/platform/wtf/hash_map.h" // nogncheck
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h" // nogncheck
#endif
namespace blink {
class BlobDataHandle;
class HTTPHeaderMap;
class WebHTTPHeaderVisitor;
class WebServiceWorkerResponsePrivate;
// Represents a response to a fetch operation. ServiceWorker uses this to
// respond to a FetchEvent dispatched by the browser. The plan is for the Cache
// and fetch() API to also use it.
class BLINK_PLATFORM_EXPORT WebServiceWorkerResponse {
public:
~WebServiceWorkerResponse() { Reset(); }
WebServiceWorkerResponse();
WebServiceWorkerResponse(const WebServiceWorkerResponse& other) {
Assign(other);
}
WebServiceWorkerResponse& operator=(const WebServiceWorkerResponse& other) {
Assign(other);
return *this;
}
void Reset();
void Assign(const WebServiceWorkerResponse&);
void SetURLList(const WebVector<WebURL>&);
const WebVector<WebURL>& UrlList() const;
void SetStatus(unsigned short);
unsigned short Status() const;
void SetStatusText(const WebString&);
const WebString& StatusText() const;
void SetResponseType(network::mojom::FetchResponseType);
network::mojom::FetchResponseType ResponseType() const;
void SetResponseSource(network::mojom::FetchResponseSource);
network::mojom::FetchResponseSource ResponseSource() const;
void SetHeader(const WebString& key, const WebString& value);
// If the key already exists, appends the value to the same key (comma
// delimited) else creates a new entry.
void AppendHeader(const WebString& key, const WebString& value);
WebVector<WebString> GetHeaderKeys() const;
WebString GetHeader(const WebString& key) const;
void VisitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
void SetBlob(const WebString& uuid,
uint64_t size,
mojo::ScopedMessagePipeHandle);
WebString BlobUUID() const;
uint64_t BlobSize() const;
mojo::ScopedMessagePipeHandle CloneBlobPtr() const;
WebString SideDataBlobUUID() const;
uint64_t SideDataBlobSize() const;
mojo::ScopedMessagePipeHandle CloneSideDataBlobPtr() const;
// Provides a more detailed error when status() is zero.
void SetError(mojom::ServiceWorkerResponseError);
mojom::ServiceWorkerResponseError GetError() const;
void SetResponseTime(base::Time);
base::Time ResponseTime() const;
void SetCacheStorageCacheName(const WebString&);
const WebString& CacheStorageCacheName() const;
void SetCorsExposedHeaderNames(const WebVector<WebString>&);
const WebVector<WebString>& CorsExposedHeaderNames() const;
#if INSIDE_BLINK
const HTTPHeaderMap& Headers() const;
void SetBlobDataHandle(scoped_refptr<BlobDataHandle>);
scoped_refptr<BlobDataHandle> GetBlobDataHandle() const;
void SetSideDataBlobDataHandle(scoped_refptr<BlobDataHandle>);
#endif
private:
WebPrivatePtr<WebServiceWorkerResponsePrivate> private_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_RESPONSE_H_
|