Changeset 80244 in webkit
- Timestamp:
- Mar 3, 2011 8:54:08 AM (13 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r80229 r80244 1 2011-03-03 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r80219. 4 http://trac.webkit.org/changeset/80219 5 https://bugs.webkit.org/show_bug.cgi?id=55680 6 7 "Causes several media test crashes" (Requested by tonyg-cr on 8 #webkit). 9 10 * src/AssociatedURLLoader.cpp: 11 (WebKit::AssociatedURLLoader::AssociatedURLLoader): 12 (WebKit::AssociatedURLLoader::~AssociatedURLLoader): 13 (WebKit::AssociatedURLLoader::loadSynchronously): 14 (WebKit::AssociatedURLLoader::loadAsynchronously): 15 (WebKit::AssociatedURLLoader::cancel): 16 (WebKit::AssociatedURLLoader::setDefersLoading): 17 (WebKit::AssociatedURLLoader::prepareRequest): 18 (WebKit::AssociatedURLLoader::willSendRequest): 19 (WebKit::AssociatedURLLoader::didSendData): 20 (WebKit::AssociatedURLLoader::didReceiveResponse): 21 (WebKit::AssociatedURLLoader::didDownloadData): 22 (WebKit::AssociatedURLLoader::didReceiveData): 23 (WebKit::AssociatedURLLoader::didReceiveCachedMetadata): 24 (WebKit::AssociatedURLLoader::didFinishLoading): 25 (WebKit::AssociatedURLLoader::didFail): 26 * src/AssociatedURLLoader.h: 27 1 28 2011-03-03 Dominic Mazzoni <dmazzoni@google.com> 2 29 -
trunk/Source/WebKit/chromium/src/AssociatedURLLoader.cpp
r80219 r80244 1 1 /* 2 * Copyright (C) 2010 , 2011Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #include "AssociatedURLLoader.h" 33 33 34 #include "DocumentThreadableLoader.h"35 #include "SubresourceLoader.h"36 #include "ThreadableLoaderClient.h"37 34 #include "WebApplicationCacheHost.h" 38 35 #include "WebDataSource.h" … … 40 37 #include "WebKit.h" 41 38 #include "WebKitClient.h" 42 #include "WebURLError.h"43 #include "WebURLLoaderClient.h"44 39 #include "WebURLRequest.h" 45 #include "WrappedResourceRequest.h"46 #include "WrappedResourceResponse.h"47 48 using namespace WebCore;49 using namespace WebKit;50 using namespace WTF;51 40 52 41 namespace WebKit { 53 42 54 // This class bridges the interface differences between WebCore and WebKit loader clients. 55 // It forwards its ThreadableLoaderClient notifications to a WebURLLoaderClient. 56 class AssociatedURLLoader::ClientAdapter : public ThreadableLoaderClient { 57 public: 58 static PassOwnPtr<ClientAdapter> create(WebURLLoader*, WebURLLoaderClient*, bool /*downloadToFile*/); 59 60 virtual void didSendData(unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/); 61 virtual void willSendRequest(ResourceRequest& /*newRequest*/, const ResourceResponse& /*redirectResponse*/); 62 63 virtual void didReceiveResponse(const ResourceResponse&); 64 virtual void didReceiveData(const char*, int /*dataLength*/); 65 virtual void didReceiveCachedMetadata(const char*, int /*dataLength*/); 66 virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishTime*/); 67 virtual void didFail(const ResourceError&); 68 69 private: 70 ClientAdapter(WebURLLoader*, WebURLLoaderClient*, bool /*downloadingToFile*/); 71 72 WebURLLoader* m_loader; 73 WebURLLoaderClient* m_client; 74 unsigned long m_downloadLength; 75 bool m_downloadingToFile; 76 }; 77 78 PassOwnPtr<AssociatedURLLoader::ClientAdapter> AssociatedURLLoader::ClientAdapter::create(WebURLLoader* loader, WebURLLoaderClient* client, bool downloadToFile) 43 AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl) 44 : m_frameImpl(frameImpl), 45 m_realLoader(webKitClient()->createURLLoader()), 46 m_realClient(0) 79 47 { 80 return adoptPtr(new ClientAdapter(loader, client, downloadToFile));81 }82 83 AssociatedURLLoader::ClientAdapter::ClientAdapter(WebURLLoader* loader, WebURLLoaderClient* client, bool downloadingToFile)84 : m_loader(loader)85 , m_client(client)86 , m_downloadLength(0)87 , m_downloadingToFile(downloadingToFile)88 {89 ASSERT(m_loader);90 ASSERT(m_client);91 }92 93 void AssociatedURLLoader::ClientAdapter::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)94 {95 WrappedResourceRequest wrappedNewRequest(newRequest);96 WrappedResourceResponse wrappedRedirectResponse(redirectResponse);97 m_client->willSendRequest(m_loader, wrappedNewRequest, wrappedRedirectResponse);98 }99 100 void AssociatedURLLoader::ClientAdapter::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)101 {102 m_client->didSendData(m_loader, bytesSent, totalBytesToBeSent);103 }104 105 void AssociatedURLLoader::ClientAdapter::didReceiveResponse(const ResourceResponse& response)106 {107 WrappedResourceResponse wrappedResponse(response);108 m_client->didReceiveResponse(m_loader, wrappedResponse);109 }110 111 void AssociatedURLLoader::ClientAdapter::didReceiveData(const char* data, int lengthReceived)112 {113 m_client->didReceiveData(m_loader, data, lengthReceived);114 m_downloadLength += lengthReceived;115 }116 117 void AssociatedURLLoader::ClientAdapter::didReceiveCachedMetadata(const char* data, int lengthReceived)118 {119 m_client->didReceiveCachedMetadata(m_loader, data, lengthReceived);120 }121 122 void AssociatedURLLoader::ClientAdapter::didFinishLoading(unsigned long identifier, double finishTime)123 {124 m_client->didFinishLoading(m_loader, finishTime);125 126 if (m_downloadingToFile) {127 int downloadLength = m_downloadLength <= INT_MAX ? m_downloadLength : INT_MAX;128 m_client->didDownloadData(m_loader, downloadLength);129 }130 }131 132 void AssociatedURLLoader::ClientAdapter::didFail(const ResourceError& error)133 {134 WebURLError webError(error);135 m_client->didFail(m_loader, webError);136 }137 138 AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl)139 : m_frameImpl(frameImpl)140 , m_client(0)141 {142 ASSERT(m_frameImpl);143 }144 145 AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl, const AssociatedURLLoaderOptions& options)146 : m_frameImpl(frameImpl)147 , m_options(options)148 , m_client(0)149 {150 ASSERT(m_frameImpl);151 48 } 152 49 … … 155 52 } 156 53 157 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \158 COMPILE_ASSERT(static_cast<int>(WebKit::webkit_name) == static_cast<int>(WebCore::webcore_name), mismatching_enums)159 160 COMPILE_ASSERT_MATCHING_ENUM(DenyCrossOriginRequests, DenyCrossOriginRequests);161 COMPILE_ASSERT_MATCHING_ENUM(UseAccessControl, UseAccessControl);162 COMPILE_ASSERT_MATCHING_ENUM(AllowCrossOriginRequests, AllowCrossOriginRequests);163 164 54 void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURLResponse& response, WebURLError& error, WebData& data) 165 55 { 166 ASSERT(0); // Synchronous loading is not supported. 56 ASSERT(!m_realClient); 57 58 WebURLRequest requestCopy(request); 59 prepareRequest(requestCopy); 60 61 m_realLoader->loadSynchronously(requestCopy, response, error, data); 167 62 } 168 63 169 64 void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebURLLoaderClient* client) 170 65 { 171 ASSERT(!m_client); 172 173 m_client = client; 174 ASSERT(m_client); 175 176 ThreadableLoaderOptions options; 177 options.sendLoadCallbacks = m_options.sendLoadCallbacks; 178 options.sniffContent = m_options.sniffContent; 179 options.allowCredentials = m_options.allowCredentials; 180 options.forcePreflight = m_options.forcePreflight; 181 options.crossOriginRequestPolicy = static_cast<WebCore::CrossOriginRequestPolicy>(options.crossOriginRequestPolicy); 66 ASSERT(!m_realClient); 182 67 183 68 WebURLRequest requestCopy(request); 184 const ResourceRequest& webcoreRequest = request.toResourceRequest(); 185 Document* webcoreDocument = m_frameImpl->frame()->document(); 186 m_clientAdapter = ClientAdapter::create(this, m_client, request.downloadToFile()); 69 prepareRequest(requestCopy); 187 70 188 m_loader = DocumentThreadableLoader::create(webcoreDocument, m_clientAdapter.get(), webcoreRequest, options); 71 m_realClient = client; 72 m_realLoader->loadAsynchronously(requestCopy, this); 189 73 } 190 74 191 75 void AssociatedURLLoader::cancel() 192 76 { 193 if (m_loader) 194 m_loader->cancel(); 77 m_realLoader->cancel(); 195 78 } 196 79 197 80 void AssociatedURLLoader::setDefersLoading(bool defersLoading) 198 81 { 199 if (m_loader) 200 m_loader->setDefersLoading(defersLoading); 82 m_realLoader->setDefersLoading(defersLoading); 83 } 84 85 void AssociatedURLLoader::prepareRequest(WebURLRequest& request) 86 { 87 WebApplicationCacheHost* applicationCacheHost = m_frameImpl->dataSource()->applicationCacheHost(); 88 if (applicationCacheHost) 89 applicationCacheHost->willStartSubResourceRequest(request); 90 m_frameImpl->dispatchWillSendRequest(request); 91 } 92 93 void AssociatedURLLoader::willSendRequest(WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse) 94 { 95 m_realClient->willSendRequest(this, newRequest, redirectResponse); 96 } 97 98 void AssociatedURLLoader::didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) 99 { 100 m_realClient->didSendData(this, bytesSent, totalBytesToBeSent); 101 } 102 103 void AssociatedURLLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& response) 104 { 105 m_realClient->didReceiveResponse(this, response); 106 } 107 108 void AssociatedURLLoader::didDownloadData(WebURLLoader*, int dataLength) 109 { 110 m_realClient->didDownloadData(this, dataLength); 111 } 112 113 void AssociatedURLLoader::didReceiveData(WebURLLoader*, const char* data, int dataLength) 114 { 115 m_realClient->didReceiveData(this, data, dataLength); 116 } 117 118 void AssociatedURLLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength) 119 { 120 m_realClient->didReceiveCachedMetadata(this, data, dataLength); 121 } 122 123 void AssociatedURLLoader::didFinishLoading(WebURLLoader*, double finishTime) 124 { 125 m_realClient->didFinishLoading(this, finishTime); 126 } 127 128 void AssociatedURLLoader::didFail(WebURLLoader*, const WebURLError& error) 129 { 130 m_realClient->didFail(this, error); 201 131 } 202 132 -
trunk/Source/WebKit/chromium/src/AssociatedURLLoader.h
r80219 r80244 1 1 /* 2 * Copyright (C) 2010 , 2011Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 34 34 #include "WebURLLoader.h" 35 #include <wtf/Noncopyable.h>35 #include "WebURLLoaderClient.h" 36 36 #include <wtf/OwnPtr.h> 37 37 #include <wtf/RefPtr.h> 38 39 namespace WebCore { class DocumentThreadableLoader; }40 38 41 39 namespace WebKit { … … 43 41 class WebFrameImpl; 44 42 45 enum CrossOriginRequestPolicy {46 DenyCrossOriginRequests,47 UseAccessControl,48 AllowCrossOriginRequests49 };50 51 struct AssociatedURLLoaderOptions {52 AssociatedURLLoaderOptions() : sendLoadCallbacks(false), sniffContent(false), allowCredentials(false), forcePreflight(false), crossOriginRequestPolicy(DenyCrossOriginRequests) { }53 bool sendLoadCallbacks;54 bool sniffContent;55 bool allowCredentials; // Whether to send HTTP credentials and cookies with the request.56 bool forcePreflight; // If AccessControl is used, whether to force a preflight.57 CrossOriginRequestPolicy crossOriginRequestPolicy;58 };59 60 43 // This class is used to implement WebFrame::createAssociatedURLLoader. 61 class AssociatedURLLoader : public WebURLLoader { 62 WTF_MAKE_NONCOPYABLE(AssociatedURLLoader); 44 // FIXME: Implement in terms of WebCore::SubresourceLoader. 45 class AssociatedURLLoader : public WebURLLoader, 46 public WebURLLoaderClient { 63 47 public: 64 48 AssociatedURLLoader(PassRefPtr<WebFrameImpl>); 65 AssociatedURLLoader(PassRefPtr<WebFrameImpl>, const AssociatedURLLoaderOptions&);66 49 ~AssociatedURLLoader(); 67 50 … … 72 55 virtual void setDefersLoading(bool); 73 56 57 // WebURLLoaderClient methods: 58 virtual void willSendRequest(WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse); 59 virtual void didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent); 60 virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&); 61 virtual void didDownloadData(WebURLLoader*, int dataLength); 62 virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength); 63 virtual void didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength); 64 virtual void didFinishLoading(WebURLLoader*, double finishTime); 65 virtual void didFail(WebURLLoader*, const WebURLError&); 66 74 67 private: 75 class ClientAdapter;68 void prepareRequest(WebURLRequest&); 76 69 77 70 RefPtr<WebFrameImpl> m_frameImpl; 78 AssociatedURLLoaderOptions m_options; 79 WebURLLoaderClient* m_client; 80 OwnPtr<ClientAdapter> m_clientAdapter; 81 RefPtr<WebCore::DocumentThreadableLoader> m_loader; 71 OwnPtr<WebURLLoader> m_realLoader; 72 WebURLLoaderClient* m_realClient; 82 73 }; 83 74
Note: See TracChangeset
for help on using the changeset viewer.