Changeset 68371 in webkit
- Timestamp:
- Sep 26, 2010 11:05:06 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r68369 r68371 1 2010-09-26 Patrick Gansterer <paroga@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Remove dead code and fix header includes in ResourceHandleWin 6 https://bugs.webkit.org/show_bug.cgi?id=46479 7 8 Also add missing member varibale from r68167. 9 10 * platform/network/ResourceHandle.h: 11 * platform/network/ResourceHandleInternal.h: 12 (WebCore::ResourceHandleInternal::ResourceHandleInternal): 13 * platform/network/win/ResourceHandleWin.cpp: 14 (WebCore::ResourceHandleInternal::~ResourceHandleInternal): 15 (WebCore::ResourceHandle::~ResourceHandle): 16 (WebCore::ResourceHandle::onRequestComplete): 17 * platform/network/win/ResourceHandleWin.h: Removed. 18 1 19 2010-09-26 Patrick Gansterer <paroga@webkit.org> 2 20 -
trunk/WebCore/platform/network/ResourceHandle.h
r68196 r68371 47 47 typedef void* LPVOID; 48 48 typedef LPVOID HINTERNET; 49 typedef unsigned WPARAM;50 typedef long LPARAM;51 typedef struct HWND__* HWND;52 typedef _W64 long LONG_PTR;53 typedef LONG_PTR LRESULT;54 49 #endif 55 50 … … 171 166 void setSynchronousInternetHandle(HINTERNET); 172 167 void fileLoadTimer(Timer<ResourceHandle>*); 173 void onHandleCreated(LPARAM);174 168 void onRedirect(); 175 169 bool onRequestComplete(); 176 170 static void CALLBACK internetStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD); 177 friend void __stdcall transferJobStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD);178 friend LRESULT __stdcall ResourceHandleWndProc(HWND, unsigned message, WPARAM, LPARAM);179 171 #endif 180 172 -
trunk/WebCore/platform/network/ResourceHandleInternal.h
r68147 r68371 93 93 #if USE(WININET) 94 94 , m_fileLoadTimer(loader, &ResourceHandle::fileLoadTimer) 95 , m_resourceHandle(0)96 , m_secondaryHandle(0)97 , m_jobId(0)98 , m_threadId(0)99 95 , m_internetHandle(0) 100 96 , m_connectHandle(0) … … 102 98 , m_sentEndRequest(false) 103 99 , m_bytesRemainingToWrite(0) 100 , m_loadSynchronously(false) 104 101 , m_hasReceivedResponse(false) 105 , m_resend(false)106 102 #endif 107 103 #if USE(CURL) … … 169 165 #if USE(WININET) 170 166 Timer<ResourceHandle> m_fileLoadTimer; 171 HINTERNET m_resourceHandle;172 HINTERNET m_secondaryHandle;173 unsigned m_jobId;174 DWORD m_threadId;175 167 HINTERNET m_internetHandle; 176 168 HINTERNET m_connectHandle; … … 178 170 bool m_sentEndRequest; 179 171 Vector<char> m_formData; 180 int m_bytesRemainingToWrite;181 String m_postReferrer;172 size_t m_bytesRemainingToWrite; 173 bool m_loadSynchronously; 182 174 bool m_hasReceivedResponse; 183 bool m_resend;184 175 String m_redirectUrl; 185 176 #endif -
trunk/WebCore/platform/network/win/ResourceHandleWin.cpp
r68196 r68371 28 28 #include "ResourceHandle.h" 29 29 30 #include "CachedResourceLoader.h" 31 #include "Document.h" 32 #include "Frame.h" 33 #include "FrameLoader.h" 34 #include "Page.h" 30 #include "HTTPParsers.h" 31 #include "MIMETypeRegistry.h" 32 #include "MainThread.h" 33 #include "NotImplemented.h" 35 34 #include "ResourceError.h" 36 35 #include "ResourceHandleClient.h" 37 36 #include "ResourceHandleInternal.h" 38 #include " ResourceHandleWin.h"37 #include "SharedBuffer.h" 39 38 #include "Timer.h" 40 #include "WebCoreInstanceHandle.h" 41 39 #include "UnusedParam.h" 42 40 #include <wtf/text/CString.h> 43 41 #include <windows.h> … … 46 44 namespace WebCore { 47 45 48 static unsigned transferJobId = 0;49 static HashMap<int, ResourceHandle*>* jobIdMap = 0;50 51 static HWND transferJobWindowHandle = 0;52 const LPCWSTR kResourceHandleWindowClassName = L"ResourceHandleWindowClass";53 54 // Message types for internal use (keep in sync with kMessageHandlers)55 enum {56 handleCreatedMessage = WM_USER,57 requestRedirectedMessage,58 requestCompleteMessage59 };60 61 typedef void (ResourceHandle:: *ResourceHandleEventHandler)(LPARAM);62 static const ResourceHandleEventHandler messageHandlers[] = {63 &ResourceHandle::onHandleCreated,64 &ResourceHandle::onRequestRedirected,65 &ResourceHandle::onRequestComplete66 };67 68 46 static inline HINTERNET createInternetHandle(const String& userAgent, bool asynchronous) 69 47 { … … 95 73 characters.removeLast(); // Remove NullTermination. 96 74 return String::adopt(characters); 97 }98 99 static int addToOutstandingJobs(ResourceHandle* job)100 {101 if (!jobIdMap)102 jobIdMap = new HashMap<int, ResourceHandle*>;103 transferJobId++;104 jobIdMap->set(transferJobId, job);105 return transferJobId;106 }107 108 static void removeFromOutstandingJobs(int jobId)109 {110 if (!jobIdMap)111 return;112 jobIdMap->remove(jobId);113 }114 115 static ResourceHandle* lookupResourceHandle(int jobId)116 {117 if (!jobIdMap)118 return 0;119 return jobIdMap->get(jobId);120 }121 122 static LRESULT CALLBACK ResourceHandleWndProc(HWND hWnd, UINT message,123 WPARAM wParam, LPARAM lParam)124 {125 if (message >= handleCreatedMessage) {126 UINT index = message - handleCreatedMessage;127 if (index < _countof(messageHandlers)) {128 unsigned jobId = (unsigned) wParam;129 ResourceHandle* job = lookupResourceHandle(jobId);130 if (job) {131 ASSERT(job->d->m_jobId == jobId);132 ASSERT(job->d->m_threadId == GetCurrentThreadId());133 (job->*(messageHandlers[index]))(lParam);134 }135 return 0;136 }137 }138 return DefWindowProc(hWnd, message, wParam, lParam);139 }140 141 static void initializeOffScreenResourceHandleWindow()142 {143 if (transferJobWindowHandle)144 return;145 146 WNDCLASSEX wcex;147 memset(&wcex, 0, sizeof(WNDCLASSEX));148 wcex.cbSize = sizeof(WNDCLASSEX);149 wcex.lpfnWndProc = ResourceHandleWndProc;150 wcex.hInstance = WebCore::instanceHandle();151 wcex.lpszClassName = kResourceHandleWindowClassName;152 RegisterClassEx(&wcex);153 154 transferJobWindowHandle = CreateWindow(kResourceHandleWindowClassName, 0, 0, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,155 HWND_MESSAGE, 0, WebCore::instanceHandle(), 0);156 75 } 157 76 … … 211 130 ResourceHandleInternal::~ResourceHandleInternal() 212 131 { 213 if (m_fileHandle != INVALID_HANDLE_VALUE)214 CloseHandle(m_fileHandle);215 132 } 216 133 217 134 ResourceHandle::~ResourceHandle() 218 135 { 219 if (d->m_jobId)220 removeFromOutstandingJobs(d->m_jobId);221 }222 223 void ResourceHandle::onHandleCreated(LPARAM lParam)224 {225 if (!d->m_resourceHandle) {226 d->m_resourceHandle = HINTERNET(lParam);227 if (d->status != 0) {228 // We were canceled before Windows actually created a handle for us, close and delete now.229 InternetCloseHandle(d->m_resourceHandle);230 delete this;231 return;232 }233 234 if (request().httpMethod() == "POST") {235 // FIXME: Too late to set referrer properly.236 String urlStr = request().url().path();237 int fragmentIndex = urlStr.find('#');238 if (fragmentIndex != -1)239 urlStr = urlStr.left(fragmentIndex);240 static LPCSTR accept[2]={"*/*", NULL};241 HINTERNET urlHandle = HttpOpenRequestA(d->m_resourceHandle,242 "POST", urlStr.latin1().data(), 0, 0, accept,243 INTERNET_FLAG_KEEP_CONNECTION |244 INTERNET_FLAG_FORMS_SUBMIT |245 INTERNET_FLAG_RELOAD |246 INTERNET_FLAG_NO_CACHE_WRITE |247 INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |248 INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP,249 (DWORD_PTR)d->m_jobId);250 if (urlHandle == INVALID_HANDLE_VALUE) {251 InternetCloseHandle(d->m_resourceHandle);252 delete this;253 }254 }255 } else if (!d->m_secondaryHandle) {256 assert(request().httpMethod() == "POST");257 d->m_secondaryHandle = HINTERNET(lParam);258 259 // Need to actually send the request now.260 String headers = "Content-Type: application/x-www-form-urlencoded\n";261 headers += "Referer: ";262 headers += d->m_postReferrer;263 headers += "\n";264 const CString& headersLatin1 = headers.latin1();265 if (firstRequest().httpBody()) {266 firstRequest().httpBody()->flatten(d->m_formData);267 d->m_bytesRemainingToWrite = d->m_formData.size();268 }269 INTERNET_BUFFERSA buffers;270 memset(&buffers, 0, sizeof(buffers));271 buffers.dwStructSize = sizeof(INTERNET_BUFFERSA);272 buffers.lpcszHeader = headersLatin1.data();273 buffers.dwHeadersLength = headers.length();274 buffers.dwBufferTotal = d->m_bytesRemainingToWrite;275 276 HttpSendRequestExA(d->m_secondaryHandle, &buffers, 0, 0, (DWORD_PTR)d->m_jobId);277 // FIXME: add proper error handling278 }279 136 } 280 137 … … 347 204 } 348 205 349 HINTERNET handle = (request().httpMethod() == "POST") ? d->m_secondaryHandle : d->m_resourceHandle;350 351 206 static const int bufferSize = 32768; 352 207 char buffer[bufferSize]; … … 401 256 deref(); // balances ref in start 402 257 return false; 403 }404 405 static void __stdcall transferJobStatusCallback(HINTERNET internetHandle,406 DWORD_PTR jobId,407 DWORD internetStatus,408 LPVOID statusInformation,409 DWORD statusInformationLength)410 {411 #ifdef RESOURCE_LOADER_DEBUG412 char buf[64];413 _snprintf(buf, sizeof(buf), "status-callback: status=%u, job=%p\n",414 internetStatus, jobId);415 OutputDebugStringA(buf);416 #endif417 418 UINT msg;419 LPARAM lParam;420 421 switch (internetStatus) {422 case INTERNET_STATUS_HANDLE_CREATED:423 // tell the main thread about the newly created handle424 msg = handleCreatedMessage;425 lParam = (LPARAM) LPINTERNET_ASYNC_RESULT(statusInformation)->dwResult;426 break;427 case INTERNET_STATUS_REQUEST_COMPLETE:428 #ifdef RESOURCE_LOADER_DEBUG429 _snprintf(buf, sizeof(buf), "request-complete: result=%p, error=%u\n",430 LPINTERNET_ASYNC_RESULT(statusInformation)->dwResult,431 LPINTERNET_ASYNC_RESULT(statusInformation)->dwError);432 OutputDebugStringA(buf);433 #endif434 // tell the main thread that the request is done435 msg = requestCompleteMessage;436 lParam = 0;437 break;438 case INTERNET_STATUS_REDIRECT:439 // tell the main thread to observe this redirect (FIXME: we probably440 // need to block the redirect at this point so the application can441 // decide whether or not to follow the redirect)442 msg = requestRedirectedMessage;443 lParam = (LPARAM) StringImpl::create((const UChar*) statusInformation,444 statusInformationLength).releaseRef();445 break;446 case INTERNET_STATUS_USER_INPUT_REQUIRED:447 // FIXME: prompt the user if necessary448 ResumeSuspendedDownload(internetHandle, 0);449 case INTERNET_STATUS_STATE_CHANGE:450 // may need to call ResumeSuspendedDownload here as well451 default:452 return;453 }454 455 PostMessage(transferJobWindowHandle, msg, (WPARAM) jobId, lParam);456 258 } 457 259
Note: See TracChangeset
for help on using the changeset viewer.