Changeset 89089 in webkit
- Timestamp:
- Jun 16, 2011 4:53:23 PM (13 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r89065 r89089 1 2011-06-16 Bill Budge <bbudge@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 The AssociatedURLLoader returns URL access errors synchronously. Use a timer to return such errors asynchronously. Also add unit tests for successful loads, same-origin restriction by default, and successful cross-origin loads. 6 https://bugs.webkit.org/show_bug.cgi?id=60059 7 8 * WebKit.gyp: 9 * WebKit.gypi: 10 * src/AssociatedURLLoader.cpp: 11 (WebKit::AssociatedURLLoader::ClientAdapter::clearClient): 12 (WebKit::AssociatedURLLoader::ClientAdapter::ClientAdapter): 13 (WebKit::AssociatedURLLoader::ClientAdapter::didFinishLoading): 14 (WebKit::AssociatedURLLoader::ClientAdapter::didFail): 15 (WebKit::AssociatedURLLoader::ClientAdapter::enableErrorNotifications): 16 (WebKit::AssociatedURLLoader::ClientAdapter::notifyError): 17 (WebKit::AssociatedURLLoader::loadAsynchronously): 18 * tests/AssociatedURLLoaderTest.cpp: Added. 19 (WebKit::TestWebFrameClient::cancelledError): 20 (WebKit::AssociatedURLLoaderTest::AssociatedURLLoaderTest): 21 (WebKit::AssociatedURLLoaderTest::SetUp): 22 (WebKit::AssociatedURLLoaderTest::TearDown): 23 (WebKit::AssociatedURLLoaderTest::serveRequests): 24 (WebKit::AssociatedURLLoaderTest::createAssociatedURLLoader): 25 (WebKit::AssociatedURLLoaderTest::willSendRequest): 26 (WebKit::AssociatedURLLoaderTest::didSendData): 27 (WebKit::AssociatedURLLoaderTest::didReceiveResponse): 28 (WebKit::AssociatedURLLoaderTest::didDownloadData): 29 (WebKit::AssociatedURLLoaderTest::didReceiveData): 30 (WebKit::AssociatedURLLoaderTest::didReceiveCachedMetadata): 31 (WebKit::AssociatedURLLoaderTest::didFinishLoading): 32 (WebKit::AssociatedURLLoaderTest::didFail): 33 (WebKit::TEST_F): 34 1 35 2011-06-16 Sailesh Agrawal <sail@chromium.org> 2 36 -
trunk/Source/WebKit/chromium/WebKit.gyp
r89008 r89089 647 647 # These tests depend on webkit_support and 648 648 # functions defined only in !WEBKIT_IMPLEMENTATION. 649 'tests/AssociatedURLLoaderTest.cpp', 649 650 'tests/WebFrameTest.cpp', 650 651 'tests/WebPageNewSerializerTest.cpp', -
trunk/Source/WebKit/chromium/WebKit.gypi
r88523 r89089 54 54 'webkit_unittest_files': [ 55 55 'tests/ArenaTestHelpers.h', 56 'tests/AssociatedURLLoaderTest.cpp', 56 57 'tests/InnerGestureRecognizerTest.cpp', 57 58 'tests/CCThreadTaskTest.cpp', -
trunk/Source/WebKit/chromium/src/AssociatedURLLoader.cpp
r89036 r89089 35 35 #include "DocumentThreadableLoaderClient.h" 36 36 #include "SubresourceLoader.h" 37 #include "Timer.h" 37 38 #include "WebApplicationCacheHost.h" 38 39 #include "WebDataSource.h" … … 55 56 // It forwards its ThreadableLoaderClient notifications to a WebURLLoaderClient. 56 57 class AssociatedURLLoader::ClientAdapter : public DocumentThreadableLoaderClient { 58 WTF_MAKE_NONCOPYABLE(ClientAdapter); 57 59 public: 58 60 static PassOwnPtr<ClientAdapter> create(AssociatedURLLoader*, WebURLLoaderClient*, bool /*downloadToFile*/); … … 69 71 virtual bool isDocumentThreadableLoaderClient() { return true; } 70 72 71 // This method stops loading and releases the DocumentThreadableLoader as early as possible. 72 void clearClient() { m_client = 0; } 73 // Enables forwarding of error notifications to the WebURLLoaderClient. These must be 74 // deferred until after the call to AssociatedURLLoader::loadAsynchronously() completes. 75 void enableErrorNotifications(); 76 77 // Stops loading and releases the DocumentThreadableLoader as early as possible. 78 void clearClient() { m_client = 0; } 73 79 74 80 private: 75 81 ClientAdapter(AssociatedURLLoader*, WebURLLoaderClient*, bool /*downloadToFile*/); 76 82 83 void notifyError(Timer<ClientAdapter>*); 84 77 85 AssociatedURLLoader* m_loader; 78 86 WebURLLoaderClient* m_client; 87 WebURLError m_error; 88 89 Timer<ClientAdapter> m_errorTimer; 79 90 unsigned long m_downloadLength; 80 91 bool m_downloadToFile; 92 bool m_enableErrorNotifications; 93 bool m_didFail; 81 94 }; 82 95 … … 89 102 : m_loader(loader) 90 103 , m_client(client) 104 , m_errorTimer(this, &ClientAdapter::notifyError) 91 105 , m_downloadLength(0) 92 106 , m_downloadToFile(downloadToFile) 107 , m_enableErrorNotifications(false) 108 , m_didFail(false) 93 109 { 94 110 ASSERT(m_loader); … … 145 161 int downloadLength = m_downloadLength <= INT_MAX ? m_downloadLength : INT_MAX; 146 162 m_client->didDownloadData(m_loader, downloadLength); 147 // While the client could have cancel led, continue, since the load finished.163 // While the client could have canceled, continue, since the load finished. 148 164 } 149 165 … … 156 172 return; 157 173 158 WebURLError webError(error); 159 m_client->didFail(m_loader, webError); 174 m_didFail = true; 175 m_error = WebURLError(error); 176 if (m_enableErrorNotifications) 177 notifyError(&m_errorTimer); 178 } 179 180 void AssociatedURLLoader::ClientAdapter::enableErrorNotifications() 181 { 182 m_enableErrorNotifications = true; 183 // If an error has already been received, start a timer to report it to the client 184 // after AssociatedURLLoader::loadAsynchronously has returned to the caller. 185 if (m_didFail) 186 m_errorTimer.startOneShot(0); 187 } 188 189 void AssociatedURLLoader::ClientAdapter::notifyError(Timer<ClientAdapter>* timer) 190 { 191 ASSERT_UNUSED(timer, timer == &m_errorTimer); 192 193 m_client->didFail(m_loader, m_error); 160 194 } 161 195 … … 216 250 Document* webcoreDocument = m_frameImpl->frame()->document(); 217 251 m_clientAdapter = ClientAdapter::create(this, m_client, request.downloadToFile()); 218 219 252 m_loader = DocumentThreadableLoader::create(webcoreDocument, m_clientAdapter.get(), webcoreRequest, options); 253 m_clientAdapter->enableErrorNotifications(); 220 254 } 221 255
Note: See TracChangeset
for help on using the changeset viewer.