Remove remaining PLATFORM(CHROMIUM)-guarded code in WebCore
[WebKit-https.git] / Source / WebCore / platform / network / ResourceHandleClient.h
1 /*
2  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
3  * Copyright (C) 2013 Apple Computer, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25  */
26
27 #ifndef ResourceHandleClient_h
28 #define ResourceHandleClient_h
29
30 #include <wtf/PassRefPtr.h>
31
32 #if USE(CFNETWORK)
33 #include <CFNetwork/CFURLCachePriv.h>
34 #include <CFNetwork/CFURLResponsePriv.h>
35 #endif
36
37 #if PLATFORM(MAC)
38 OBJC_CLASS NSCachedURLResponse;
39 #endif
40
41 namespace WebCore {
42     class AuthenticationChallenge;
43     class Credential;
44     class KURL;
45     class ProtectionSpace;
46     class ResourceHandle;
47     class ResourceError;
48     class ResourceRequest;
49     class ResourceResponse;
50     class SharedBuffer;
51
52     enum CacheStoragePolicy {
53         StorageAllowed,
54         StorageAllowedInMemoryOnly,
55         StorageNotAllowed
56     };
57     
58     class ResourceHandleClient {
59     public:
60         ResourceHandleClient();
61         virtual ~ResourceHandleClient();
62
63         // Request may be modified.
64         virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& /*redirectResponse*/) { }
65         virtual void didSendData(ResourceHandle*, unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { }
66
67         virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { }
68         
69         virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/) { }
70         virtual void didReceiveBuffer(ResourceHandle*, PassRefPtr<SharedBuffer>, int encodedDataLength);
71         
72         virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/) { }
73         virtual void didFail(ResourceHandle*, const ResourceError&) { }
74         virtual void wasBlocked(ResourceHandle*) { }
75         virtual void cannotShowURL(ResourceHandle*) { }
76
77         virtual bool usesAsyncCallbacks() { return false; }
78         // Client will pass an updated request using ResourceHandle::continueWillSendRequest() when ready.
79         virtual void willSendRequestAsync(ResourceHandle*, const ResourceRequest&, const ResourceResponse& redirectResponse);
80         // Client will pass an updated request using ResourceHandle::continueShouldUseCredentialStorage() when ready.
81         virtual void shouldUseCredentialStorageAsync(ResourceHandle*);
82 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
83         // Client will pass an updated request using ResourceHandle::continueCanAuthenticateAgainstProtectionSpace() when ready.
84         virtual void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&);
85 #endif
86 #if PLATFORM(MAC)
87         // Client will pass an updated request using ResourceHandle::continueWillCacheResponse() when ready.
88         virtual void willCacheResponseAsync(ResourceHandle*, NSCachedURLResponse *);
89 #endif
90
91 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
92         virtual bool supportsDataArray() { return false; }
93         virtual void didReceiveDataArray(ResourceHandle*, CFArrayRef) { }
94 #endif
95
96 #if USE(SOUP)
97         virtual char* getBuffer(int requestedLength, int* actualLength);
98 #endif
99
100         virtual bool shouldUseCredentialStorage(ResourceHandle*) { return false; }
101         virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
102         virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
103 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
104         virtual bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace&) { return false; }
105 #endif
106         virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge&) { }
107
108 #if PLATFORM(MAC)
109 #if USE(CFNETWORK)
110         virtual CFCachedURLResponseRef willCacheResponse(ResourceHandle*, CFCachedURLResponseRef response) { return response; }
111 #else
112         virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse *response) { return response; }
113 #endif
114         virtual void willStopBufferingData(ResourceHandle*, const char*, int) { }
115 #endif // PLATFORM(MAC)
116 #if PLATFORM(WIN) && USE(CFNETWORK)
117         virtual bool shouldCacheResponse(ResourceHandle*, CFCachedURLResponseRef) { return true; }
118 #endif
119
120 #if USE(SOUP)
121 private:
122         char* m_buffer;
123 #endif
124     };
125
126 }
127
128 #endif