Changeset 68371 in webkit


Ignore:
Timestamp:
Sep 26, 2010 11:05:06 PM (14 years ago)
Author:
Patrick Gansterer
Message:

2010-09-26 Patrick Gansterer <Patrick Gansterer>

Reviewed by Adam Barth.

Remove dead code and fix header includes in ResourceHandleWin
https://bugs.webkit.org/show_bug.cgi?id=46479

Also add missing member varibale from r68167.

  • platform/network/ResourceHandle.h:
  • platform/network/ResourceHandleInternal.h: (WebCore::ResourceHandleInternal::ResourceHandleInternal):
  • platform/network/win/ResourceHandleWin.cpp: (WebCore::ResourceHandleInternal::~ResourceHandleInternal): (WebCore::ResourceHandle::~ResourceHandle): (WebCore::ResourceHandle::onRequestComplete):
  • platform/network/win/ResourceHandleWin.h: Removed.
Location:
trunk/WebCore
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r68369 r68371  
     12010-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
    1192010-09-26  Patrick Gansterer  <paroga@webkit.org>
    220
  • trunk/WebCore/platform/network/ResourceHandle.h

    r68196 r68371  
    4747typedef void* LPVOID;
    4848typedef 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;
    5449#endif
    5550
     
    171166    void setSynchronousInternetHandle(HINTERNET);
    172167    void fileLoadTimer(Timer<ResourceHandle>*);
    173     void onHandleCreated(LPARAM);
    174168    void onRedirect();
    175169    bool onRequestComplete();
    176170    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);
    179171#endif
    180172
  • trunk/WebCore/platform/network/ResourceHandleInternal.h

    r68147 r68371  
    9393#if USE(WININET)
    9494            , m_fileLoadTimer(loader, &ResourceHandle::fileLoadTimer)
    95             , m_resourceHandle(0)
    96             , m_secondaryHandle(0)
    97             , m_jobId(0)
    98             , m_threadId(0)
    9995            , m_internetHandle(0)
    10096            , m_connectHandle(0)
     
    10298            , m_sentEndRequest(false)
    10399            , m_bytesRemainingToWrite(0)
     100            , m_loadSynchronously(false)
    104101            , m_hasReceivedResponse(false)
    105             , m_resend(false)
    106102#endif
    107103#if USE(CURL)
     
    169165#if USE(WININET)
    170166        Timer<ResourceHandle> m_fileLoadTimer;
    171         HINTERNET m_resourceHandle;
    172         HINTERNET m_secondaryHandle;
    173         unsigned m_jobId;
    174         DWORD m_threadId;
    175167        HINTERNET m_internetHandle;
    176168        HINTERNET m_connectHandle;
     
    178170        bool m_sentEndRequest;
    179171        Vector<char> m_formData;
    180         int m_bytesRemainingToWrite;
    181         String m_postReferrer;
     172        size_t m_bytesRemainingToWrite;
     173        bool m_loadSynchronously;
    182174        bool m_hasReceivedResponse;
    183         bool m_resend;
    184175        String m_redirectUrl;
    185176#endif
  • trunk/WebCore/platform/network/win/ResourceHandleWin.cpp

    r68196 r68371  
    2828#include "ResourceHandle.h"
    2929
    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"
    3534#include "ResourceError.h"
    3635#include "ResourceHandleClient.h"
    3736#include "ResourceHandleInternal.h"
    38 #include "ResourceHandleWin.h"
     37#include "SharedBuffer.h"
    3938#include "Timer.h"
    40 #include "WebCoreInstanceHandle.h"
    41 
     39#include "UnusedParam.h"
    4240#include <wtf/text/CString.h>
    4341#include <windows.h>
     
    4644namespace WebCore {
    4745
    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   requestCompleteMessage
    59 };
    60 
    61 typedef void (ResourceHandle:: *ResourceHandleEventHandler)(LPARAM);
    62 static const ResourceHandleEventHandler messageHandlers[] = {
    63     &ResourceHandle::onHandleCreated,
    64     &ResourceHandle::onRequestRedirected,
    65     &ResourceHandle::onRequestComplete
    66 };
    67 
    6846static inline HINTERNET createInternetHandle(const String& userAgent, bool asynchronous)
    6947{
     
    9573    characters.removeLast(); // Remove NullTermination.
    9674    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);
    15675}
    15776
     
    211130ResourceHandleInternal::~ResourceHandleInternal()
    212131{
    213     if (m_fileHandle != INVALID_HANDLE_VALUE)
    214         CloseHandle(m_fileHandle);
    215132}
    216133
    217134ResourceHandle::~ResourceHandle()
    218135{
    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 handling
    278     }
    279136}
    280137
     
    347204    }
    348205
    349     HINTERNET handle = (request().httpMethod() == "POST") ? d->m_secondaryHandle : d->m_resourceHandle;
    350 
    351206    static const int bufferSize = 32768;
    352207    char buffer[bufferSize];
     
    401256    deref(); // balances ref in start
    402257    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_DEBUG
    412     char buf[64];
    413     _snprintf(buf, sizeof(buf), "status-callback: status=%u, job=%p\n",
    414               internetStatus, jobId);
    415     OutputDebugStringA(buf);
    416 #endif
    417 
    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 handle
    424         msg = handleCreatedMessage;
    425         lParam = (LPARAM) LPINTERNET_ASYNC_RESULT(statusInformation)->dwResult;
    426         break;
    427     case INTERNET_STATUS_REQUEST_COMPLETE:
    428 #ifdef RESOURCE_LOADER_DEBUG
    429         _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 #endif
    434         // tell the main thread that the request is done
    435         msg = requestCompleteMessage;
    436         lParam = 0;
    437         break;
    438     case INTERNET_STATUS_REDIRECT:
    439         // tell the main thread to observe this redirect (FIXME: we probably
    440         // need to block the redirect at this point so the application can
    441         // 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 necessary
    448         ResumeSuspendedDownload(internetHandle, 0);
    449     case INTERNET_STATUS_STATE_CHANGE:
    450         // may need to call ResumeSuspendedDownload here as well
    451     default:
    452         return;
    453     }
    454 
    455     PostMessage(transferJobWindowHandle, msg, (WPARAM) jobId, lParam);
    456258}
    457259
Note: See TracChangeset for help on using the changeset viewer.