diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp')
-rw-r--r-- | WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp index 825366a..09b07d6 100644 --- a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp @@ -35,7 +35,6 @@ #include <comutil.h> #include <sstream> #include <tchar.h> -#include <wtf/HashMap.h> #include <wtf/Vector.h> using namespace std; @@ -60,26 +59,17 @@ static inline BSTR BSTRFromString(const string& str) return result; } -typedef HashMap<unsigned long, wstring> IdentifierMap; - -IdentifierMap& urlMap() -{ - static IdentifierMap urlMap; - - return urlMap; -} - -static wstring descriptionSuitableForTestResult(unsigned long identifier) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(unsigned long identifier) const { - IdentifierMap::iterator it = urlMap().find(identifier); + IdentifierMap::const_iterator it = m_urlMap.find(identifier); - if (it == urlMap().end()) + if (it == m_urlMap.end()) return L"<unknown>"; return urlSuitableForTestResult(it->second); } -static wstring descriptionSuitableForTestResult(IWebURLRequest* request) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLRequest* request) { if (!request) return L"(null)"; @@ -108,7 +98,7 @@ static wstring descriptionSuitableForTestResult(IWebURLRequest* request) return L"<NSURLRequest URL " + url + L", main document URL " + mainDocumentURL + L", http method " + httpMethod + L">"; } -static wstring descriptionSuitableForTestResult(IWebURLResponse* response) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebURLResponse* response) { if (!response) return L"(null)"; @@ -128,7 +118,7 @@ static wstring descriptionSuitableForTestResult(IWebURLResponse* response) return L"<NSURLResponse " + url + L", http status code " + wstringFromInt(statusCode) + L">"; } -static wstring descriptionSuitableForTestResult(IWebError* error, unsigned long identifier) +wstring ResourceLoadDelegate::descriptionSuitableForTestResult(IWebError* error, unsigned long identifier) const { wstring result = L"<NSError "; @@ -197,6 +187,8 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::QueryInterface(REFIID riid, void *ppvObject = static_cast<IWebResourceLoadDelegate*>(this); else if (IsEqualGUID(riid, IID_IWebResourceLoadDelegate)) *ppvObject = static_cast<IWebResourceLoadDelegate*>(this); + else if (IsEqualGUID(riid, IID_IWebResourceLoadDelegatePrivate2)) + *ppvObject = static_cast<IWebResourceLoadDelegatePrivate2*>(this); else return E_NOINTERFACE; @@ -229,12 +221,22 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::identifierForInitialRequest( if (FAILED(request->URL(&urlStr))) return E_FAIL; + ASSERT(!urlMap().contains(identifier)); urlMap().set(identifier, wstringFromBSTR(urlStr)); } return S_OK; } +HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::removeIdentifierForRequest( + /* [in] */ IWebView* webView, + /* [in] */ unsigned long identifier) +{ + urlMap().remove(identifier); + + return S_OK; +} + HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest( /* [in] */ IWebView* webView, /* [in] */ unsigned long identifier, @@ -351,11 +353,12 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFinishLoadingFromDataSource( { if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) { printf("%S - didFinishLoading\n", - descriptionSuitableForTestResult(identifier).c_str()), - urlMap().remove(identifier); + descriptionSuitableForTestResult(identifier).c_str()); } - return S_OK; + removeIdentifierForRequest(webView, identifier); + + return S_OK; } HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFailLoadingWithError( @@ -368,8 +371,9 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didFailLoadingWithError( printf("%S - didFailLoadingWithError: %S\n", descriptionSuitableForTestResult(identifier).c_str(), descriptionSuitableForTestResult(error, identifier).c_str()); - urlMap().remove(identifier); } + removeIdentifierForRequest(webView, identifier); + return S_OK; } |