blob: b28ad036efcbda369ba7ce4f8a42b782c533c7fe [file] [log] [blame]
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +00001/*
2 * Copyright (C) 2012 Google, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
mjs@apple.com92047332014-03-15 04:08:27 +000016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef CachedResourceRequest_h
27#define CachedResourceRequest_h
28
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000029#include "CachedResource.h"
beidson@apple.comb98919a2015-03-23 22:34:53 +000030#include "DocumentLoader.h"
eric@webkit.orgf3f6e042013-02-11 05:14:03 +000031#include "Element.h"
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000032#include "ResourceLoadPriority.h"
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000033#include "ResourceLoaderOptions.h"
34#include "ResourceRequest.h"
commit-queue@webkit.org7049f922016-09-22 08:57:12 +000035#include "SecurityOrigin.h"
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000036#include <wtf/RefPtr.h>
37#include <wtf/text/AtomicString.h>
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000038
39namespace WebCore {
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000040
41namespace ContentExtensions {
42struct BlockedStatus;
43}
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000044class Document;
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000045
46class CachedResourceRequest {
47public:
commit-queue@webkit.org77951322016-10-11 06:42:53 +000048 CachedResourceRequest(ResourceRequest&&, const ResourceLoaderOptions&, Optional<ResourceLoadPriority> = Nullopt, String&& charset = String());
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000049
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000050 ResourceRequest&& releaseResourceRequest() { return WTFMove(m_resourceRequest); }
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000051 const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
52 const String& charset() const { return m_charset; }
53 void setCharset(const String& charset) { m_charset = charset; }
54 const ResourceLoaderOptions& options() const { return m_options; }
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000055 void setOptions(const ResourceLoaderOptions& options) { m_options = options; }
cdumez@apple.com8da16fb2015-02-04 01:23:58 +000056 const Optional<ResourceLoadPriority>& priority() const { return m_priority; }
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000057 void setInitiator(PassRefPtr<Element>);
simonjam@chromium.org5928faa2012-11-22 00:18:35 +000058 void setInitiator(const AtomicString& name);
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000059 const AtomicString& initiatorName() const;
commit-queue@webkit.org877e1492016-08-02 06:46:57 +000060 bool allowsCaching() const { return m_options.cachingPolicy == CachingPolicy::AllowCaching; }
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000061 void setCachingPolicy(CachingPolicy policy) { m_options.cachingPolicy = policy; }
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000062
youenn.fablet@crf.canon.fr70851bfd2016-06-10 18:17:11 +000063 void setAsPotentiallyCrossOrigin(const String&, Document&);
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000064 void updateForAccessControl(Document&);
65
66 void upgradeInsecureRequestIfNeeded(Document&);
67 void setAcceptHeaderIfNone(CachedResource::Type);
68 void updateAccordingCacheMode();
69 void removeFragmentIdentifierIfNeeded();
70#if ENABLE(CONTENT_EXTENSIONS)
71 void applyBlockedStatus(const ContentExtensions::BlockedStatus&);
72#endif
73#if ENABLE(CACHE_PARTITIONING)
74 void setDomainForCachePartition(Document&);
75#endif
76
commit-queue@webkit.org7049f922016-09-22 08:57:12 +000077 void setOrigin(RefPtr<SecurityOrigin>&& origin) { ASSERT(!m_origin); m_origin = WTFMove(origin); }
78 RefPtr<SecurityOrigin> releaseOrigin() { return WTFMove(m_origin); }
79 SecurityOrigin* origin() const { return m_origin.get(); }
youenn.fablet@crf.canon.fr70851bfd2016-06-10 18:17:11 +000080
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000081private:
82 ResourceRequest m_resourceRequest;
83 String m_charset;
84 ResourceLoaderOptions m_options;
cdumez@apple.com8da16fb2015-02-04 01:23:58 +000085 Optional<ResourceLoadPriority> m_priority;
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000086 RefPtr<Element> m_initiatorElement;
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000087 AtomicString m_initiatorName;
commit-queue@webkit.org7049f922016-09-22 08:57:12 +000088 RefPtr<SecurityOrigin> m_origin;
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000089};
90
91} // namespace WebCore
92
93#endif