2 * Copyright (C) 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, 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
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * 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.
27 #include "WebKitDLL.h"
28 #include "WebDownload.h"
30 #include "DefaultDownloadDelegate.h"
31 #include "MarshallingHelpers.h"
34 #include "WebKitLogging.h"
35 #include "WebMutableURLRequest.h"
36 #include "WebURLAuthenticationChallenge.h"
37 #include "WebURLCredential.h"
38 #include "WebURLResponse.h"
40 #include <wtf/platform.h>
41 #include <wtf/text/CString.h>
45 #include <sys/types.h>
47 #include <WebCore/AuthenticationCF.h>
48 #include <WebCore/BString.h>
49 #include <WebCore/CredentialStorage.h>
50 #include <WebCore/DownloadBundle.h>
51 #include <WebCore/LoaderRunLoopCF.h>
52 #include <WebCore/ResourceError.h>
53 #include <WebCore/ResourceHandle.h>
54 #include <WebCore/ResourceRequest.h>
55 #include <WebCore/ResourceResponse.h>
56 #include <wtf/CurrentTime.h>
58 using namespace WebCore;
60 // CFURLDownload Callbacks ----------------------------------------------------------------
61 static void didStartCallback(CFURLDownloadRef download, const void *clientInfo);
62 static CFURLRequestRef willSendRequestCallback(CFURLDownloadRef download, CFURLRequestRef request, CFURLResponseRef redirectionResponse, const void *clientInfo);
63 static void didReceiveAuthenticationChallengeCallback(CFURLDownloadRef download, CFURLAuthChallengeRef challenge, const void *clientInfo);
64 static void didReceiveResponseCallback(CFURLDownloadRef download, CFURLResponseRef response, const void *clientInfo);
65 static void willResumeWithResponseCallback(CFURLDownloadRef download, CFURLResponseRef response, UInt64 startingByte, const void *clientInfo);
66 static void didReceiveDataCallback(CFURLDownloadRef download, CFIndex length, const void *clientInfo);
67 static Boolean shouldDecodeDataOfMIMETypeCallback(CFURLDownloadRef download, CFStringRef encodingType, const void *clientInfo);
68 static void decideDestinationWithSuggestedObjectNameCallback(CFURLDownloadRef download, CFStringRef objectName, const void *clientInfo);
69 static void didCreateDestinationCallback(CFURLDownloadRef download, CFURLRef path, const void *clientInfo);
70 static void didFinishCallback(CFURLDownloadRef download, const void *clientInfo);
71 static void didFailCallback(CFURLDownloadRef download, CFErrorRef error, const void *clientInfo);
73 void WebDownload::init(ResourceHandle* handle, const ResourceRequest& request, const ResourceResponse& response, IWebDownloadDelegate* delegate)
75 m_delegate = delegate ? delegate : DefaultDownloadDelegate::sharedInstance();
76 CFURLConnectionRef connection = handle->connection();
78 LOG_ERROR("WebDownload::WebDownload(ResourceHandle*,...) called with an inactive ResourceHandle");
82 CFURLDownloadClient client = {0, this, 0, 0, 0, didStartCallback, willSendRequestCallback, didReceiveAuthenticationChallengeCallback,
83 didReceiveResponseCallback, willResumeWithResponseCallback, didReceiveDataCallback, shouldDecodeDataOfMIMETypeCallback,
84 decideDestinationWithSuggestedObjectNameCallback, didCreateDestinationCallback, didFinishCallback, didFailCallback};
86 m_request.adoptRef(WebMutableURLRequest::createInstance(request));
87 m_download.adoptCF(CFURLDownloadCreateAndStartWithLoadingConnection(0, connection, request.cfURLRequest(), response.cfURLResponse(), &client));
89 // It is possible for CFURLDownloadCreateAndStartWithLoadingConnection() to fail if the passed in CFURLConnection is not in a "downloadable state"
90 // However, we should never hit that case
93 LOG_ERROR("WebDownload - Failed to create WebDownload from existing connection (%s)", request.url().string().utf8().data());
95 LOG(Download, "WebDownload - Created WebDownload %p from existing connection (%s)", this, request.url().string().utf8().data());
97 // The CFURLDownload either starts successfully and retains the CFURLConnection,
98 // or it fails to creating and we have a now-useless connection with a dangling ref.
99 // Either way, we need to release the connection to balance out ref counts
100 handle->releaseConnectionForDownload();
101 CFRelease(connection);
104 void WebDownload::init(const KURL& url, IWebDownloadDelegate* delegate)
106 m_delegate = delegate ? delegate : DefaultDownloadDelegate::sharedInstance();
107 LOG_ERROR("Delegate is %p", m_delegate.get());
109 ResourceRequest request(url);
110 CFURLRequestRef cfRequest = request.cfURLRequest();
112 CFURLDownloadClient client = {0, this, 0, 0, 0, didStartCallback, willSendRequestCallback, didReceiveAuthenticationChallengeCallback,
113 didReceiveResponseCallback, willResumeWithResponseCallback, didReceiveDataCallback, shouldDecodeDataOfMIMETypeCallback,
114 decideDestinationWithSuggestedObjectNameCallback, didCreateDestinationCallback, didFinishCallback, didFailCallback};
115 m_request.adoptRef(WebMutableURLRequest::createInstance(request));
116 m_download.adoptCF(CFURLDownloadCreate(0, cfRequest, &client));
118 CFURLDownloadScheduleWithCurrentMessageQueue(m_download.get());
119 CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
121 LOG(Download, "WebDownload - Initialized download of url %s in WebDownload %p", url.string().utf8().data(), this);
124 // IWebDownload -------------------------------------------------------------------
126 HRESULT STDMETHODCALLTYPE WebDownload::initWithRequest(
127 /* [in] */ IWebURLRequest* request,
128 /* [in] */ IWebDownloadDelegate* delegate)
130 COMPtr<WebMutableURLRequest> webRequest;
131 if (!request || FAILED(request->QueryInterface(&webRequest))) {
132 LOG(Download, "WebDownload - initWithRequest failed - not a WebMutableURLRequest");
138 m_delegate = delegate;
139 LOG(Download, "Delegate is %p", m_delegate.get());
141 RetainPtr<CFURLRequestRef> cfRequest = webRequest->resourceRequest().cfURLRequest();
143 CFURLDownloadClient client = {0, this, 0, 0, 0, didStartCallback, willSendRequestCallback, didReceiveAuthenticationChallengeCallback,
144 didReceiveResponseCallback, willResumeWithResponseCallback, didReceiveDataCallback, shouldDecodeDataOfMIMETypeCallback,
145 decideDestinationWithSuggestedObjectNameCallback, didCreateDestinationCallback, didFinishCallback, didFailCallback};
146 m_request.adoptRef(WebMutableURLRequest::createInstance(webRequest.get()));
147 m_download.adoptCF(CFURLDownloadCreate(0, cfRequest.get(), &client));
149 // If for some reason the download failed to create,
150 // we have particular cleanup to do
156 CFURLDownloadScheduleWithCurrentMessageQueue(m_download.get());
157 CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
159 LOG(Download, "WebDownload - initWithRequest complete, started download of url %s", webRequest->resourceRequest().url().string().utf8().data());
163 HRESULT STDMETHODCALLTYPE WebDownload::initToResumeWithBundle(
164 /* [in] */ BSTR bundlePath,
165 /* [in] */ IWebDownloadDelegate* delegate)
167 LOG(Download, "Attempting resume of download bundle %s", String(bundlePath, SysStringLen(bundlePath)).ascii().data());
169 RetainPtr<CFDataRef> resumeData(AdoptCF, DownloadBundle::extractResumeData(String(bundlePath, SysStringLen(bundlePath))));
176 m_delegate = delegate;
177 LOG(Download, "Delegate is %p", m_delegate.get());
179 CFURLDownloadClient client = {0, this, 0, 0, 0, didStartCallback, willSendRequestCallback, didReceiveAuthenticationChallengeCallback,
180 didReceiveResponseCallback, willResumeWithResponseCallback, didReceiveDataCallback, shouldDecodeDataOfMIMETypeCallback,
181 decideDestinationWithSuggestedObjectNameCallback, didCreateDestinationCallback, didFinishCallback, didFailCallback};
183 RetainPtr<CFURLRef> pathURL(AdoptCF, MarshallingHelpers::PathStringToFileCFURLRef(String(bundlePath, SysStringLen(bundlePath))));
186 m_download.adoptCF(CFURLDownloadCreateWithResumeData(0, resumeData.get(), pathURL.get(), &client));
189 LOG(Download, "Failed to create CFURLDownloadRef for resume");
193 m_bundlePath = String(bundlePath, SysStringLen(bundlePath));
194 // Attempt to remove the ".download" extension from the bundle for the final file destination
195 // Failing that, we clear m_destination and will ask the delegate later once the download starts
196 if (m_bundlePath.endsWith(DownloadBundle::fileExtension(), false)) {
197 m_destination = m_bundlePath.isolatedCopy();
198 m_destination.truncate(m_destination.length() - DownloadBundle::fileExtension().length());
200 m_destination = String();
202 CFURLDownloadScheduleWithCurrentMessageQueue(m_download.get());
203 CFURLDownloadScheduleDownloadWithRunLoop(m_download.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
205 LOG(Download, "WebDownload - initWithRequest complete, resumed download of bundle %s", String(bundlePath, SysStringLen(bundlePath)).ascii().data());
209 HRESULT STDMETHODCALLTYPE WebDownload::start()
211 LOG(Download, "WebDownload - Starting download (%p)", this);
215 CFURLDownloadStart(m_download.get());
216 // FIXME: 4950477 - CFURLDownload neglects to make the didStart() client call upon starting the download.
217 // This is a somewhat critical call, so we'll fake it for now!
223 HRESULT STDMETHODCALLTYPE WebDownload::cancel()
225 LOG(Download, "WebDownload - Cancelling download (%p)", this);
229 CFURLDownloadCancel(m_download.get());
234 HRESULT STDMETHODCALLTYPE WebDownload::cancelForResume()
236 LOG(Download, "WebDownload - Cancelling download (%p), writing resume information to file if possible", this);
242 RetainPtr<CFDataRef> resumeData;
243 if (m_destination.isEmpty()) {
244 CFURLDownloadCancel(m_download.get());
248 CFURLDownloadSetDeletesUponFailure(m_download.get(), false);
249 CFURLDownloadCancel(m_download.get());
251 resumeData.adoptCF(CFURLDownloadCopyResumeData(m_download.get()));
253 LOG(Download, "WebDownload - Unable to create resume data for download (%p)", this);
257 DownloadBundle::appendResumeData(resumeData.get(), m_bundlePath);
264 HRESULT STDMETHODCALLTYPE WebDownload::deletesFileUponFailure(
265 /* [out, retval] */ BOOL* result)
269 *result = CFURLDownloadDeletesUponFailure(m_download.get());
273 HRESULT STDMETHODCALLTYPE WebDownload::setDeletesFileUponFailure(
274 /* [in] */ BOOL deletesFileUponFailure)
278 CFURLDownloadSetDeletesUponFailure(m_download.get(), !!deletesFileUponFailure);
282 HRESULT STDMETHODCALLTYPE WebDownload::setDestination(
283 /* [in] */ BSTR path,
284 /* [in] */ BOOL allowOverwrite)
289 m_destination = String(path, SysStringLen(path));
290 m_bundlePath = m_destination + DownloadBundle::fileExtension();
292 CFURLRef pathURL = MarshallingHelpers::PathStringToFileCFURLRef(m_bundlePath);
293 CFURLDownloadSetDestination(m_download.get(), pathURL, !!allowOverwrite);
296 LOG(Download, "WebDownload - Set destination to %s", m_bundlePath.ascii().data());
301 // IWebURLAuthenticationChallengeSender -------------------------------------------------------------------
303 HRESULT STDMETHODCALLTYPE WebDownload::cancelAuthenticationChallenge(
304 /* [in] */ IWebURLAuthenticationChallenge*)
307 CFURLDownloadCancel(m_download.get());
311 // FIXME: Do we need a URL or description for this error code?
312 ResourceError error(String(WebURLErrorDomain), WebURLErrorUserCancelledAuthentication, "", "");
313 COMPtr<WebError> webError(AdoptCOM, WebError::createInstance(error));
314 m_delegate->didFailWithError(this, webError.get());
319 HRESULT STDMETHODCALLTYPE WebDownload::continueWithoutCredentialForAuthenticationChallenge(
320 /* [in] */ IWebURLAuthenticationChallenge* challenge)
322 COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
324 return E_NOINTERFACE;
327 CFURLDownloadUseCredential(m_download.get(), 0, webChallenge->authenticationChallenge().cfURLAuthChallengeRef());
331 HRESULT STDMETHODCALLTYPE WebDownload::useCredential(
332 /* [in] */ IWebURLCredential* credential,
333 /* [in] */ IWebURLAuthenticationChallenge* challenge)
335 COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
337 return E_NOINTERFACE;
339 COMPtr<WebURLCredential> webCredential(Query, credential);
341 return E_NOINTERFACE;
343 RetainPtr<CFURLCredentialRef> cfCredential(AdoptCF, createCF(webCredential->credential()));
346 CFURLDownloadUseCredential(m_download.get(), cfCredential.get(), webChallenge->authenticationChallenge().cfURLAuthChallengeRef());
350 // CFURLDownload Callbacks -------------------------------------------------------------------
351 void WebDownload::didStart()
354 m_startTime = m_dataTime = currentTime();
356 LOG(Download, "DOWNLOAD - Started %p at %.3f seconds", this, m_startTime);
358 if (FAILED(m_delegate->didBegin(this)))
359 LOG_ERROR("DownloadDelegate->didBegin failed");
362 CFURLRequestRef WebDownload::willSendRequest(CFURLRequestRef request, CFURLResponseRef response)
364 COMPtr<WebMutableURLRequest> webRequest(AdoptCOM, WebMutableURLRequest::createInstance(ResourceRequest(request)));
365 COMPtr<WebURLResponse> webResponse(AdoptCOM, WebURLResponse::createInstance(ResourceResponse(response)));
366 COMPtr<IWebMutableURLRequest> finalRequest;
368 if (FAILED(m_delegate->willSendRequest(this, webRequest.get(), webResponse.get(), &finalRequest)))
369 LOG_ERROR("DownloadDelegate->willSendRequest failed");
374 COMPtr<WebMutableURLRequest> finalWebRequest(AdoptCOM, WebMutableURLRequest::createInstance(finalRequest.get()));
375 m_request = finalWebRequest.get();
376 CFURLRequestRef result = finalWebRequest->resourceRequest().cfURLRequest();
381 void WebDownload::didReceiveAuthenticationChallenge(CFURLAuthChallengeRef challenge)
383 // Try previously stored credential first.
384 if (!CFURLAuthChallengeGetPreviousFailureCount(challenge)) {
385 Credential credential = CredentialStorage::get(core(CFURLAuthChallengeGetProtectionSpace(challenge)));
386 if (!credential.isEmpty()) {
387 RetainPtr<CFURLCredentialRef> cfCredential(AdoptCF, createCF(credential));
388 CFURLDownloadUseCredential(m_download.get(), cfCredential.get(), challenge);
393 COMPtr<IWebURLAuthenticationChallenge> webChallenge(AdoptCOM,
394 WebURLAuthenticationChallenge::createInstance(AuthenticationChallenge(challenge, 0), this));
396 if (SUCCEEDED(m_delegate->didReceiveAuthenticationChallenge(this, webChallenge.get())))
399 cancelAuthenticationChallenge(webChallenge.get());
402 void WebDownload::didReceiveResponse(CFURLResponseRef response)
404 COMPtr<WebURLResponse> webResponse(AdoptCOM, WebURLResponse::createInstance(ResourceResponse(response)));
405 if (FAILED(m_delegate->didReceiveResponse(this, webResponse.get())))
406 LOG_ERROR("DownloadDelegate->didReceiveResponse failed");
409 void WebDownload::willResumeWithResponse(CFURLResponseRef response, UInt64 fromByte)
411 COMPtr<WebURLResponse> webResponse(AdoptCOM, WebURLResponse::createInstance(ResourceResponse(response)));
412 if (FAILED(m_delegate->willResumeWithResponse(this, webResponse.get(), fromByte)))
413 LOG_ERROR("DownloadDelegate->willResumeWithResponse failed");
416 void WebDownload::didReceiveData(CFIndex length)
419 m_received += length;
420 double current = currentTime();
421 if (current - m_dataTime > 2.0)
422 LOG(Download, "DOWNLOAD - %p hanged for %.3f seconds - Received %i bytes for a total of %i", this, current - m_dataTime, length, m_received);
423 m_dataTime = current;
425 if (FAILED(m_delegate->didReceiveDataOfLength(this, length)))
426 LOG_ERROR("DownloadDelegate->didReceiveData failed");
429 bool WebDownload::shouldDecodeDataOfMIMEType(CFStringRef mimeType)
432 if (FAILED(m_delegate->shouldDecodeSourceDataOfMIMEType(this, BString(mimeType), &result))) {
433 LOG_ERROR("DownloadDelegate->shouldDecodeSourceDataOfMIMEType failed");
439 void WebDownload::decideDestinationWithSuggestedObjectName(CFStringRef name)
441 if (FAILED(m_delegate->decideDestinationWithSuggestedFilename(this, BString(name))))
442 LOG_ERROR("DownloadDelegate->decideDestinationWithSuggestedObjectName failed");
445 void WebDownload::didCreateDestination(CFURLRef destination)
447 // The concept of the ".download bundle" is internal to the WebDownload, so therefore
448 // we try to mask the delegate from its existence as much as possible by telling it the final
449 // destination was created, when in reality the bundle was created
451 String createdDestination = MarshallingHelpers::FileCFURLRefToPathString(destination);
453 // At this point in receiving CFURLDownload callbacks, we should definitely have the bundle path stored locally
454 // and it should match with the file that CFURLDownload created
455 ASSERT(createdDestination == m_bundlePath);
456 // And we should also always have the final-destination stored
457 ASSERT(!m_destination.isEmpty());
459 BString path(m_destination);
460 if (FAILED(m_delegate->didCreateDestination(this, path)))
461 LOG_ERROR("DownloadDelegate->didCreateDestination failed");
464 void WebDownload::didFinish()
467 LOG(Download, "DOWNLOAD - Finished %p after %i bytes and %.3f seconds", this, m_received, currentTime() - m_startTime);
470 ASSERT(!m_bundlePath.isEmpty() && !m_destination.isEmpty());
471 LOG(Download, "WebDownload - Moving file from bundle %s to destination %s", m_bundlePath.ascii().data(), m_destination.ascii().data());
473 // We try to rename the bundle to the final file name. If that fails, we give the delegate one more chance to chose
474 // the final file name, then we just leave it
475 if (!MoveFileEx(m_bundlePath.charactersWithNullTermination(), m_destination.charactersWithNullTermination(), 0)) {
476 LOG_ERROR("Failed to move bundle %s to %s on completion\nError - %i", m_bundlePath.ascii().data(), m_destination.ascii().data(), GetLastError());
478 bool reportBundlePathAsFinalPath = true;
480 BString destinationBSTR(m_destination.characters(), m_destination.length());
481 if (FAILED(m_delegate->decideDestinationWithSuggestedFilename(this, destinationBSTR)))
482 LOG_ERROR("delegate->decideDestinationWithSuggestedFilename() failed");
484 // The call to m_delegate->decideDestinationWithSuggestedFilename() should have changed our destination, so we'll try the move
486 if (!m_destination.isEmpty())
487 if (MoveFileEx(m_bundlePath.charactersWithNullTermination(), m_destination.charactersWithNullTermination(), 0))
488 reportBundlePathAsFinalPath = false;
490 // We either need to tell the delegate our final filename is the bundle filename, or is the file name they just told us to use
491 if (reportBundlePathAsFinalPath) {
492 BString bundleBSTR(m_bundlePath);
493 m_delegate->didCreateDestination(this, bundleBSTR);
495 BString finalDestinationBSTR = BString(m_destination);
496 m_delegate->didCreateDestination(this, finalDestinationBSTR);
500 // It's extremely likely the call to delegate->didFinish() will deref this, so lets not let that cause our destruction just yet
501 COMPtr<WebDownload> protect = this;
502 if (FAILED(m_delegate->didFinish(this)))
503 LOG_ERROR("DownloadDelegate->didFinish failed");
508 void WebDownload::didFail(CFErrorRef error)
510 COMPtr<WebError> webError(AdoptCOM, WebError::createInstance(ResourceError(error)));
511 if (FAILED(m_delegate->didFailWithError(this, webError.get())))
512 LOG_ERROR("DownloadDelegate->didFailWithError failed");
515 // CFURLDownload Callbacks ----------------------------------------------------------------
516 void didStartCallback(CFURLDownloadRef, const void *clientInfo)
517 { ((WebDownload*)clientInfo)->didStart(); }
519 CFURLRequestRef willSendRequestCallback(CFURLDownloadRef, CFURLRequestRef request, CFURLResponseRef redirectionResponse, const void *clientInfo)
520 { return ((WebDownload*)clientInfo)->willSendRequest(request, redirectionResponse); }
522 void didReceiveAuthenticationChallengeCallback(CFURLDownloadRef, CFURLAuthChallengeRef challenge, const void *clientInfo)
523 { ((WebDownload*)clientInfo)->didReceiveAuthenticationChallenge(challenge); }
525 void didReceiveResponseCallback(CFURLDownloadRef, CFURLResponseRef response, const void *clientInfo)
526 { ((WebDownload*)clientInfo)->didReceiveResponse(response); }
528 void willResumeWithResponseCallback(CFURLDownloadRef, CFURLResponseRef response, UInt64 startingByte, const void *clientInfo)
529 { ((WebDownload*)clientInfo)->willResumeWithResponse(response, startingByte); }
531 void didReceiveDataCallback(CFURLDownloadRef, CFIndex length, const void *clientInfo)
532 { ((WebDownload*)clientInfo)->didReceiveData(length); }
534 Boolean shouldDecodeDataOfMIMETypeCallback(CFURLDownloadRef, CFStringRef encodingType, const void *clientInfo)
535 { return ((WebDownload*)clientInfo)->shouldDecodeDataOfMIMEType(encodingType); }
537 void decideDestinationWithSuggestedObjectNameCallback(CFURLDownloadRef, CFStringRef objectName, const void *clientInfo)
538 { ((WebDownload*)clientInfo)->decideDestinationWithSuggestedObjectName(objectName); }
540 void didCreateDestinationCallback(CFURLDownloadRef, CFURLRef path, const void *clientInfo)
541 { ((WebDownload*)clientInfo)->didCreateDestination(path); }
543 void didFinishCallback(CFURLDownloadRef, const void *clientInfo)
544 { ((WebDownload*)clientInfo)->didFinish(); }
546 void didFailCallback(CFURLDownloadRef, CFErrorRef error, const void *clientInfo)
547 { ((WebDownload*)clientInfo)->didFail(error); }