Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSURLCache.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSURLCache; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSCachedURLResponse; | |
18 import dwt.internal.cocoa.NSInteger; | |
19 import dwt.internal.cocoa.NSObject; | |
20 import dwt.internal.cocoa.NSString; | |
21 import dwt.internal.cocoa.NSURLRequest; | |
22 import dwt.internal.cocoa.OS; | |
23 import objc = dwt.internal.objc.runtime; | |
24 | |
25 enum NSURLCacheStoragePolicy | |
26 { | |
27 NSURLCacheStorageAllowed, | |
28 NSURLCacheStorageAllowedInMemoryOnly, | |
29 NSURLCacheStorageNotAllowed, | |
30 } | |
31 | |
32 alias NSURLCacheStoragePolicy.NSURLCacheStorageAllowed NSURLCacheStorageAllowed; | |
33 alias NSURLCacheStoragePolicy.NSURLCacheStorageAllowedInMemoryOnly NSURLCacheStorageAllowedInMemoryOnly; | |
34 alias NSURLCacheStoragePolicy.NSURLCacheStorageNotAllowed NSURLCacheStorageNotAllowed; | |
35 | |
36 public class NSURLCache : NSObject | |
37 { | |
38 | |
39 public this () | |
40 { | |
41 super(); | |
42 } | |
43 | |
44 public this (objc.id id) | |
45 { | |
46 super(id); | |
47 } | |
48 | |
49 public NSCachedURLResponse cachedResponseForRequest (NSURLRequest request) | |
50 { | |
51 objc.id result = OS.objc_msgSend(this.id, OS.sel_cachedResponseForRequest_1, request !is null ? request.id : null); | |
52 return result !is null ? new NSCachedURLResponse(result) : null; | |
53 } | |
54 | |
55 public NSUInteger currentDiskUsage () | |
56 { | |
57 return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_currentDiskUsage); | |
58 } | |
59 | |
60 public NSUInteger currentMemoryUsage () | |
61 { | |
62 return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_currentMemoryUsage); | |
63 } | |
64 | |
65 public NSUInteger diskCapacity () | |
66 { | |
67 return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_diskCapacity); | |
68 } | |
69 | |
70 public id initWithMemoryCapacity (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) | |
71 { | |
72 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMemoryCapacity_1diskCapacity_1diskPath_1, memoryCapacity, diskCapacity, | |
73 path !is null ? path.id : null); | |
74 return result !is null ? new id(result) : null; | |
75 } | |
76 | |
77 public NSUInteger memoryCapacity () | |
78 { | |
79 return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_memoryCapacity); | |
80 } | |
81 | |
82 public void removeAllCachedResponses () | |
83 { | |
84 OS.objc_msgSend(this.id, OS.sel_removeAllCachedResponses); | |
85 } | |
86 | |
87 public void removeCachedResponseForRequest (NSURLRequest request) | |
88 { | |
89 OS.objc_msgSend(this.id, OS.sel_removeCachedResponseForRequest_1, request !is null ? request.id : null); | |
90 } | |
91 | |
92 public void setDiskCapacity (NSUInteger diskCapacity) | |
93 { | |
94 OS.objc_msgSend(this.id, OS.sel_setDiskCapacity_1, diskCapacity); | |
95 } | |
96 | |
97 public void setMemoryCapacity (NSUInteger memoryCapacity) | |
98 { | |
99 OS.objc_msgSend(this.id, OS.sel_setMemoryCapacity_1, memoryCapacity); | |
100 } | |
101 | |
102 public static void setSharedURLCache (NSURLCache cache) | |
103 { | |
104 OS.objc_msgSend(OS.class_NSURLCache, OS.sel_setSharedURLCache_1, cache !is null ? cache.id : null); | |
105 } | |
106 | |
107 public static NSURLCache sharedURLCache () | |
108 { | |
109 objc.id result = OS.objc_msgSend(OS.class_NSURLCache, OS.sel_sharedURLCache); | |
110 return result !is null ? new NSURLCache(result) : null; | |
111 } | |
112 | |
113 public void storeCachedResponse (NSCachedURLResponse cachedResponse, NSURLRequest request) | |
114 { | |
115 OS.objc_msgSend(this.id, OS.sel_storeCachedResponse_1forRequest_1, cachedResponse !is null ? cachedResponse.id : null, | |
116 request !is null ? request.id : null); | |
117 } | |
118 | |
119 } |