efad071b99af29a6815dad834126abf8c2d506a3
[WebKit-https.git] / Source / WebCore / platform / spi / cf / CFNetworkSPI.h
1 /*
2  * Copyright (C) 2014 Apple 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 APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef CFNetworkSPI_h
27 #define CFNetworkSPI_h
28
29 #include <CFNetwork/CFNetwork.h>
30
31 #if PLATFORM(WIN) || USE(APPLE_INTERNAL_SDK)
32
33 #include <CFNetwork/CFHTTPCookies.h>
34 #include <CFNetwork/CFHTTPCookiesPriv.h>
35 #include <CFNetwork/CFURLCachePriv.h>
36 #include <CFNetwork/CFURLProtocolPriv.h>
37 #include <CFNetwork/CFURLRequest.h>
38
39 // FIXME: Remove the defined(__OBJC__)-guard onnce we fix <rdar://problem/19033610>.
40 #if defined(__OBJC__) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)
41 // FIXME: As a workaround for <rdar://problem/18337182>, we conditionally enclose the header
42 // in an extern "C" linkage block to make it suitable for C++ use.
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 #import <CFNetwork/CFNSURLConnection.h>
48
49 #ifdef __cplusplus
50 }
51 #endif
52 #endif // defined(__OBJC__) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)
53
54 #else
55
56 typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
57 typedef const struct _CFCachedURLResponse* CFCachedURLResponseRef;
58 typedef const struct _CFURLCache* CFURLCacheRef;
59 typedef const struct _CFURLRequest *CFURLRequestRef;
60 typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
61 typedef const struct __CFData *CFDataRef;
62
63 #ifdef __BLOCKS__
64 typedef void (^CFCachedURLResponseCallBackBlock)(CFCachedURLResponseRef);
65 #endif
66
67 #endif // PLATFORM(WIN) || USE(APPLE_INTERNAL_SDK)
68
69 EXTERN_C void CFURLRequestSetShouldStartSynchronously(CFURLRequestRef, Boolean);
70
71 EXTERN_C CFURLCacheRef CFURLCacheCopySharedURLCache();
72 EXTERN_C void CFURLCacheSetMemoryCapacity(CFURLCacheRef, CFIndex memoryCapacity);
73 EXTERN_C void _CFURLCachePurgeMemoryCache(CFURLCacheRef);
74 #if PLATFORM(COCOA)
75 EXTERN_C CFBooleanRef _CFURLCacheIsResponseDataMemMapped(CFURLCacheRef, CFDataRef);
76 EXTERN_C void _CFURLCacheSetMinSizeForVMCachedResource(CFURLCacheRef, CFIndex);
77
78 EXTERN_C Boolean _CFNetworkIsKnownHSTSHostWithSession(CFURLRef, CFURLStorageSessionRef);
79 EXTERN_C void _CFNetworkResetHSTSHostsWithSession(CFURLStorageSessionRef);
80 #endif
81
82 EXTERN_C void CFHTTPCookieStorageDeleteAllCookies(CFHTTPCookieStorageRef);
83
84 #if PLATFORM(COCOA)
85 EXTERN_C CFDataRef _CFCachedURLResponseGetMemMappedData(CFCachedURLResponseRef);
86 #ifdef __BLOCKS__
87 EXTERN_C void _CFCachedURLResponseSetBecameFileBackedCallBackBlock(CFCachedURLResponseRef, CFCachedURLResponseCallBackBlock, dispatch_queue_t);
88 #endif
89 #endif // PLATFORM(COCOA)
90
91 EXTERN_C void CFURLConnectionInvalidateConnectionCache();
92
93 EXTERN_C CFStringRef const kCFHTTPCookieLocalFileDomain;
94
95 // FIXME: We should only forward declare this SPI when building for iOS without the Apple Internal SDK.
96 // As a workaround for <rdar://problem/19025016>, we must forward declare this SPI regardless of whether
97 // we are building with the Apple Internal SDK.
98 #if defined(__OBJC__) && PLATFORM(IOS)
99 @interface NSURLCache (Details)
100 -(id)_initWithMemoryCapacity:(NSUInteger)memoryCapacity diskCapacity:(NSUInteger)diskCapacity relativePath:(NSString *)path;
101 @end
102 #endif
103
104 #if defined(__OBJC__) && (!USE(APPLE_INTERNAL_SDK) || PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090)
105 enum : NSUInteger {
106     NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain = 3,
107 };
108
109 @interface NSCachedURLResponse (Details)
110 -(id)_initWithCFCachedURLResponse:(CFCachedURLResponseRef)cachedResponse;
111 -(CFCachedURLResponseRef)_CFCachedURLResponse;
112 @end
113 #endif
114
115 #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
116 EXTERN_C CFDataRef _CFNetworkCopyATSContext(void);
117 EXTERN_C Boolean _CFNetworkSetATSContext(CFDataRef);
118 #endif
119
120 #if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)
121 EXTERN_C void _CFNetworkResetHSTSHostsSinceDate(CFURLStorageSessionRef, CFDateRef);
122 #endif
123
124 #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
125 EXTERN_C CFDataRef CFHTTPCookieStorageCreateIdentifyingData(CFAllocatorRef inAllocator, CFHTTPCookieStorageRef inStorage);
126 EXTERN_C CFHTTPCookieStorageRef CFHTTPCookieStorageCreateFromIdentifyingData(CFAllocatorRef inAllocator, CFDataRef inData);
127 EXTERN_C CFArrayRef _CFHTTPParsedCookiesWithResponseHeaderFields(CFAllocatorRef inAllocator, CFDictionaryRef headerFields, CFURLRef inURL);
128 #endif
129
130 #if defined(__OBJC__)
131
132 #if !USE(APPLE_INTERNAL_SDK) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1090)
133 @interface NSHTTPCookieStorage (Details)
134 - (void)removeCookiesSinceDate:(NSDate *)date;
135 - (id)_initWithCFHTTPCookieStorage:(CFHTTPCookieStorageRef)cfStorage;
136 - (CFHTTPCookieStorageRef)_cookieStorage;
137 - (void)_saveCookies;
138 @end
139 #endif
140
141 // FIXME: Move +_setSharedHTTPCookieStorage: into the above section under !USE(APPLE_INTERNAL_SDK) when possible (soon).
142 #if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
143 @interface NSHTTPCookieStorage (Details)
144 + (void)_setSharedHTTPCookieStorage:(NSHTTPCookieStorage *)storage;
145 @end
146 #endif
147 #endif
148
149 #endif // CFNetworkSPI_h