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

Side by Side Diff: Source/modules/serviceworkers/FetchRequestData.h

Issue 329853012: [ServiceWorker] Make Request class better conformance with the spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase and fix test Created 6 years, 5 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 2014 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 #ifndef FetchRequestData_h
6 #define FetchRequestData_h
7
8 #include "platform/weborigin/KURL.h"
9 #include "wtf/PassOwnPtr.h"
10 #include "wtf/PassRefPtr.h"
11 #include "wtf/RefCounted.h"
12 #include "wtf/text/AtomicString.h"
13 #include "wtf/text/WTFString.h"
14
15 namespace blink {
16 class WebServiceWorkerRequest;
17 }
18
19 namespace WebCore {
20
21 class ExecutionContext;
22 class FetchHeaderList;
23 struct ResourceLoaderOptions;
24 class ResourceRequest;
25 class SecurityOrigin;
26 struct ThreadableLoaderOptions;
27
28
falken 2014/07/03 10:05:32 extra newline
horo 2014/07/03 12:40:30 Done.
29 class FetchRequestData : public RefCounted<FetchRequestData> {
30 public:
31 enum Mode { SameOriginMode, NoCORSMode, CORSMode, CORSWithForcedPreflight };
32 enum Credentials { OmitCredentials, SameOriginCredentials, IncludeCredential s };
33 enum Context { ChildContext, ConnectContext, DownloadContext, FontContext, F ormContext, ImageContext, ManifestContext, MediaContext, NavigateContext, Object Context, PingContext, PopupContext, PrefetchContext, ScriptContext, ServiceWorke rContext, SharedWorkerContext, StyleContext, WorkerContext, NullContext };
34 enum Tainting { BasicTainting, CORSTainting, OpaqueTainting };
35
36 class Referrer {
37 public:
38 Referrer() : m_type(ClientReferrer) { }
39 ~Referrer() { }
40 bool isNone() const { return m_type == NoneReferrer; }
41 bool isClient() const { return m_type == ClientReferrer; }
42 bool isURL() const { return m_type == URLReferrer; }
43 void setNone() { m_referrerURL = ""; m_type = NoneReferrer; }
falken 2014/07/03 10:05:32 make this multi-line
horo 2014/07/03 12:40:30 Done.
44 void setClient(const String& url)
45 {
46 // FIXME: Support Referrer Policy.
47 m_referrerURL = url;
48 m_type = ClientReferrer;
49 }
50 void setURL(const String& url)
51 {
52 m_referrerURL = url;
53 m_type = URLReferrer;
54 }
55 String getUrl() const { return m_referrerURL; }
56 private:
57 enum Type { NoneReferrer, ClientReferrer, URLReferrer };
58 Type m_type;
59 String m_referrerURL;
60 };
61
62 static PassRefPtr<FetchRequestData> create(ExecutionContext*);
63 static PassRefPtr<FetchRequestData> create(const blink::WebServiceWorkerRequ est&);
64 PassRefPtr<FetchRequestData> createRestrictedCopy(ExecutionContext*, PassRef Ptr<SecurityOrigin>) const;
65 ~FetchRequestData();
66
67 void setMethod(AtomicString method) { m_method = method; }
68 const AtomicString method() const { return m_method; }
69 void setURL(const KURL& url) { m_url = url; }
70 const KURL& url() const { return m_url; }
71 bool unsafeRequestFlag() const { return m_unsafeRequestFlag; }
72 PassRefPtr<SecurityOrigin> origin() { return m_origin; }
73 bool sameOriginDataURLFlag() { return m_sameOriginDataURLFlag; }
74 const Referrer& referrer() const { return m_referrer; }
75 void setMode(Mode mode) { m_mode = mode; }
76 Mode mode() const { return m_mode; }
77 void setCredentials(Credentials credentials) { m_credentials = credentials; }
78 Credentials credentials() const { return m_credentials; }
79 void setResponseTainting(Tainting tainting) { m_responseTainting = tainting; }
80 Tainting tainting() const { return m_responseTainting; }
81 FetchHeaderList* headerList() { return m_headerList.get(); }
82
83 private:
84 FetchRequestData();
85
86 AtomicString m_method;
87 KURL m_url;
88 RefPtr<FetchHeaderList> m_headerList;
89 bool m_unsafeRequestFlag;
90 // FIXME: Support body.
91 // FIXME: Support m_skipServiceWorkerFlag;
92 Context m_context;
93 RefPtr<SecurityOrigin> m_origin;
94 // FIXME: Support m_forceOriginHeaderFlag;
95 bool m_sameOriginDataURLFlag;
96 Referrer m_referrer;
97 // FIXME: Support m_authenticationFlag;
98 // FIXME: Support m_synchronousFlag;
99 Mode m_mode;
100 Credentials m_credentials;
101 // FIXME: Support m_useURLCredentialsFlag;
102 // FIXME: Support m_manualRedirectFlag;
103 // FIXME: Support m_redirectCount;
104 Tainting m_responseTainting;
105 };
106
107 } // namespace WebCore
108
109 #endif // FetchRequestData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698