Changeset 65835 in webkit
- Timestamp:
- Aug 23, 2010 3:12:03 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r65833 r65835 1 2010-08-23 Patrick Gansterer <paroga@paroga.com> 2 3 Reviewed by Adam Roben. 4 5 Move filehandling into fileLoadTimer callback 6 https://bugs.webkit.org/show_bug.cgi?id=43714 7 8 Also add mimetype detection for local files. 9 10 * platform/network/ResourceHandleInternal.h: 11 (WebCore::ResourceHandleInternal::ResourceHandleInternal): 12 * platform/network/win/ResourceHandleWin.cpp: 13 (WebCore::ResourceHandle::start): 14 (WebCore::ResourceHandle::fileLoadTimer): 15 1 16 2010-08-23 Iain Merrick <husky@google.com> 2 17 -
trunk/WebCore/platform/network/ResourceHandleInternal.h
r63332 r65835 93 93 #endif 94 94 #if USE(WININET) 95 , m_fileHandle(INVALID_HANDLE_VALUE)96 95 , m_fileLoadTimer(loader, &ResourceHandle::fileLoadTimer) 97 96 , m_resourceHandle(0) … … 171 170 #endif 172 171 #if USE(WININET) 173 HANDLE m_fileHandle;174 172 Timer<ResourceHandle> m_fileLoadTimer; 175 173 HINTERNET m_resourceHandle; -
trunk/WebCore/platform/network/win/ResourceHandleWin.cpp
r61183 r65835 1 1 /* 2 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 334 335 ref(); 335 336 if (request().url().isLocalFile()) { 336 String path = request().url().path();337 // windows does not enjoy a leading slash on paths338 if (path[0] == '/')339 path = path.substring(1);340 // FIXME: This is wrong. Need to use wide version of this call.341 d->m_fileHandle = CreateFileA(path.utf8().data(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);342 343 // FIXME: perhaps this error should be reported asynchronously for344 // consistency.345 if (d->m_fileHandle == INVALID_HANDLE_VALUE) {346 delete this;347 return false;348 }349 350 337 d->m_fileLoadTimer.startOneShot(0.0); 351 338 return true; … … 410 397 } 411 398 412 void ResourceHandle::fileLoadTimer(Timer<ResourceHandle>* timer) 413 { 399 void ResourceHandle::fileLoadTimer(Timer<ResourceHandle>*) 400 { 401 RefPtr<ResourceHandle> protector(this); 402 deref(); // balances ref in start 403 404 String fileName = firstRequest().url().fileSystemPath(); 405 HANDLE fileHandle = CreateFileW(fileName.charactersWithNullTermination(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 406 407 if (fileHandle == INVALID_HANDLE_VALUE) { 408 client()->didFail(this, ResourceError()); 409 return; 410 } 411 414 412 ResourceResponse response; 413 414 int dotPos = fileName.reverseFind('.'); 415 int slashPos = fileName.reverseFind('/'); 416 417 if (slashPos < dotPos && dotPos != -1) { 418 String ext = fileName.substring(dotPos + 1); 419 response.setMimeType(MIMETypeRegistry::getMIMETypeForExtension(ext)); 420 } 421 415 422 client()->didReceiveResponse(this, response); 416 423 … … 421 428 const int bufferSize = 8192; 422 429 char buffer[bufferSize]; 423 result = ReadFile( d->m_fileHandle, &buffer, bufferSize, &bytesRead, NULL);430 result = ReadFile(fileHandle, &buffer, bufferSize, &bytesRead, 0); 424 431 if (result && bytesRead) 425 432 client()->didReceiveData(this, buffer, bytesRead, 0); 426 // Check for end of file. 433 // Check for end of file. 427 434 } while (result && bytesRead); 428 435 429 // FIXME: handle errors better 430 431 CloseHandle(d->m_fileHandle); 432 d->m_fileHandle = INVALID_HANDLE_VALUE; 436 CloseHandle(fileHandle); 433 437 434 438 client()->didFinishLoading(this);
Note: See TracChangeset
for help on using the changeset viewer.