webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
WebDownload.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007, 2015 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. ``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 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.
24  */
25 
26 #pragma once
27 
28 #include "WebKit.h"
29 #include <WebCore/COMPtr.h>
30 #include <wtf/RetainPtr.h>
31 #include <wtf/text/WTFString.h>
32 
33 #if USE(CFURLCONNECTION)
34 #include <CFNetwork/CFURLDownloadPriv.h>
35 #elif USE(CURL)
36 #include <WebCore/CurlDownload.h>
37 #endif
38 
39 namespace WebCore {
40  class URL;
41  class ResourceHandle;
42  class ResourceRequest;
43  class ResourceResponse;
44 }
45 
46 class WebDownload
47 : public IWebDownload
49 #if USE(CURL)
51 #endif
52 {
53 public:
54  static WebDownload* createInstance(const WebCore::URL&, IWebDownloadDelegate*);
56  static WebDownload* createInstance();
57 private:
58  WebDownload();
60  void init(const WebCore::URL&, IWebDownloadDelegate*);
61  ~WebDownload();
62 public:
63  // IUnknown
64  virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject);
65  virtual ULONG STDMETHODCALLTYPE AddRef();
66  virtual ULONG STDMETHODCALLTYPE Release();
67 
68  // IWebDownload
69  virtual HRESULT STDMETHODCALLTYPE initWithRequest(_In_opt_ IWebURLRequest*, _In_opt_ IWebDownloadDelegate*);
70  virtual HRESULT STDMETHODCALLTYPE initToResumeWithBundle(_In_ BSTR bundlePath, _In_opt_ IWebDownloadDelegate*);
71  virtual HRESULT STDMETHODCALLTYPE canResumeDownloadDecodedWithEncodingMIMEType(_In_ BSTR mimeType, _Out_ BOOL* result);
72  virtual HRESULT STDMETHODCALLTYPE start();
73  virtual HRESULT STDMETHODCALLTYPE cancel();
74  virtual HRESULT STDMETHODCALLTYPE cancelForResume();
75  virtual HRESULT STDMETHODCALLTYPE deletesFileUponFailure(_Out_ BOOL* result);
76  virtual HRESULT STDMETHODCALLTYPE bundlePathForTargetPath(_In_ BSTR target, __deref_out_opt BSTR* bundle);
77  virtual HRESULT STDMETHODCALLTYPE request(_COM_Outptr_opt_ IWebURLRequest**);
78  virtual HRESULT STDMETHODCALLTYPE setDeletesFileUponFailure(BOOL);
79  virtual HRESULT STDMETHODCALLTYPE setDestination(_In_ BSTR path, BOOL allowOverwrite);
80 
81  // IWebURLAuthenticationChallengeSender
82  virtual HRESULT STDMETHODCALLTYPE cancelAuthenticationChallenge(_In_opt_ IWebURLAuthenticationChallenge*);
83  virtual HRESULT STDMETHODCALLTYPE continueWithoutCredentialForAuthenticationChallenge(_In_opt_ IWebURLAuthenticationChallenge*);
84  virtual HRESULT STDMETHODCALLTYPE useCredential(_In_opt_ IWebURLCredential*, _In_opt_ IWebURLAuthenticationChallenge*);
85 
86 #if USE(CFURLCONNECTION)
87  // CFURLDownload Callbacks
88  void didStart();
90  void didReceiveAuthenticationChallenge(CFURLAuthChallengeRef);
91  void didReceiveResponse(CFURLResponseRef);
92  void willResumeWithResponse(CFURLResponseRef, UInt64);
93  void didReceiveData(CFIndex);
94  bool shouldDecodeDataOfMIMEType(CFStringRef);
95  void decideDestinationWithSuggestedObjectName(CFStringRef);
96  void didCreateDestination(CFURLRef);
97  void didFinish();
98  void didFail(CFErrorRef);
99 #elif USE(CURL)
100  virtual void didReceiveResponse();
101  virtual void didReceiveDataOfLength(int size);
102  virtual void didFinish();
103  virtual void didFail();
104 #endif
105 
106 protected:
107  ULONG m_refCount { 0 };
108 
111 #if USE(CFURLCONNECTION)
112  RetainPtr<CFURLDownloadRef> m_download;
113 #elif USE(CURL)
114  RefPtr<WebCore::CurlDownload> m_download;
115 #endif
118 
119 #ifndef NDEBUG
120  double m_startTime;
121  double m_dataTime;
123 #endif
124 };
COMPtr< IWebMutableURLRequest > m_request
Definition: WebDownload.h:116
Definition: ResourceRequest.h:41
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
const struct __CFURL * CFURLRef
Definition: WebKitSystemInterface.h:58
Definition: IWebURLRequest.idl:46
Definition: RTCConfiguration.idl:27
WTF::String m_bundlePath
Definition: WebDownload.h:110
EGLContext EGLenum target
Definition: eglext.h:192
path
Definition: generate.py:74
unsigned long ULONG
Definition: MD5.h:32
Definition: IWebURLAuthenticationChallenge.idl:198
Definition: IWebDownload.idl:133
Definition: IWebDownload.idl:61
HRESULT
Definition: ScrollbarThemeWin.cpp:74
Definition: WTFString.h:78
sender AddRef()
GLuint start
Definition: gl2ext.h:323
double m_startTime
Definition: WebDownload.h:120
const struct __CFString * CFStringRef
Definition: WebCoreSystemInterface.h:31
wchar_t * BSTR
Definition: BString.h:36
Definition: IWebURLAuthenticationChallenge.idl:51
const struct _CFURLRequest * CFURLRequestRef
Definition: WebKitSystemInterface.h:32
Definition: CurlDownload.h:81
Definition: IWebURLAuthenticationChallenge.idl:100
double m_dataTime
Definition: WebDownload.h:121
int Release(RepeatedCompositeContainer *self)
Definition: repeated_composite_container.cc:458
WTF::String m_destination
Definition: WebDownload.h:109
result
Definition: target-blank-opener-post-window.php:5
void init()
Definition: HTMLNames.cpp:1637
struct _CFURLResponse * CFURLResponseRef
Definition: WebKitSystemInterface.h:31
COMPtr< IWebDownloadDelegate > m_delegate
Definition: WebDownload.h:117
Definition: WebDownload.h:58
Definition: URL.h:52
const CString & bundlePath()
Definition: BundlePath.mm:43
Definition: ResourceResponse.h:39
HANDLE hTheme BOOL
Definition: ScrollbarThemeWin.cpp:76
int m_received
Definition: WebDownload.h:122
Definition: EncryptedMediaExtensions.idl:84
This file is generated by create-http-header-name-table, do not edit.
Definition: CharsetData.cpp:6
CFAllocatorRef CFURLRef URL
Definition: AVFoundationCFSoftLinking.h:225
Definition: ResourceHandle.h:93