Changeset 63704 in webkit
- Timestamp:
- Jul 19, 2010 6:19:55 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r63701 r63704 1 2010-07-19 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Darin Adler, Adam Roben, Dan Bernstein and Sam Weinig. 4 5 Handle NP_ASFILE and NP_ASFILEONLY transfer modes 6 https://bugs.webkit.org/show_bug.cgi?id=42587 7 8 * WebCore.exp.in: 9 Export functions from FileSystem.h 10 11 * platform/mac/FileSystemMac.mm: 12 (WebCore::openTemporaryFile): 13 Try to create a temporary file using mkstemp. 14 1 15 2010-07-19 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/WebCore/WebCore.exp.in
r63701 r63704 140 140 __ZN7WebCore10StringImplcvP8NSStringEv 141 141 __ZN7WebCore20SpaceSplitStringData12createVectorEv 142 __ZN7WebCore10deleteFileERKNS_6StringE 142 143 __ZN7WebCore10handCursorEv 143 144 __ZN7WebCore10setCookiesEPNS_8DocumentERKNS_4KURLERKNS_6StringE … … 203 204 __ZN7WebCore11IconFetcher6createEPNS_5FrameEPNS_17IconFetcherClientE 204 205 __ZN7WebCore11RenderLayer19scrollRectToVisibleERKNS_7IntRectEbRKNS_15ScrollAlignmentES6_ 205 __ZNK7WebCore11RenderLayer19absoluteBoundingBoxEv206 206 __ZN7WebCore11globalPointERK8_NSPointP8NSWindow 207 207 __ZN7WebCore11toUserSpaceERK7_NSRectP8NSWindow 208 __ZN7WebCore11writeToFileEiPKci 208 209 __ZN7WebCore12ChromeClient20paintCustomScrollbarEPNS_15GraphicsContextERKNS_9FloatRectENS_20ScrollbarControlSizeEjNS_13ScrollbarPartEbffj 209 210 __ZN7WebCore12ChromeClient23paintCustomScrollCornerEPNS_15GraphicsContextERKNS_9FloatRectE … … 402 403 __ZN7WebCore17HistoryController26saveDocumentAndScrollStateEv 403 404 __ZN7WebCore17nameForCursorTypeENS_6Cursor4TypeE 405 __ZN7WebCore17openTemporaryFileEPKcRi 404 406 __ZN7WebCore18deprecatedParseURLERKNS_6StringE 405 407 __ZN7WebCore18isStartOfParagraphERKNS_15VisiblePositionE … … 786 788 __ZN7WebCore9TimerBaseC2Ev 787 789 __ZN7WebCore9TimerBaseD2Ev 788 __ZN7WebCore9 toElementEN3JSC7JSValueE790 __ZN7WebCore9closeFileERi 789 791 __ZN7WebCore9fontCacheEv 790 792 __ZN7WebCore9makeRangeERKNS_15VisiblePositionES2_ 791 793 __ZN7WebCore9pageCacheEv 794 __ZN7WebCore9toElementEN3JSC7JSValueE 792 795 __ZN7WebCoreeqERKNS_19ResourceRequestBaseES2_ 793 796 __ZNK3JSC8Bindings10RootObject12globalObjectEv … … 826 829 __ZNK7WebCore11HistoryItem9urlStringEv 827 830 __ZNK7WebCore11HistoryItem9viewStateEv 831 __ZNK7WebCore11RenderLayer19absoluteBoundingBoxEv 828 832 __ZNK7WebCore11RenderStyle21visitedDependentColorEi 829 833 __ZNK7WebCore11ScriptValue9getStringEPN3JSC9ExecStateERNS_6StringE -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r63696 r63704 1071 1071 514185EE0CD65F0400763C99 /* ChangeVersionWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 514185EC0CD65F0400763C99 /* ChangeVersionWrapper.h */; }; 1072 1072 514185EF0CD65F0400763C99 /* ChangeVersionWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514185ED0CD65F0400763C99 /* ChangeVersionWrapper.cpp */; }; 1073 514B3F730C722047000530DF /* FileSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 514B3F720C722047000530DF /* FileSystem.h */; };1073 514B3F730C722047000530DF /* FileSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 514B3F720C722047000530DF /* FileSystem.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1074 1074 514B3F760C722055000530DF /* FileSystemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514B3F750C722055000530DF /* FileSystemMac.mm */; }; 1075 1075 514C76370CE9225E007EF3CD /* JSSQLError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C76350CE9225E007EF3CD /* JSSQLError.cpp */; }; -
trunk/WebCore/platform/mac/FileSystemMac.mm
r35002 r63704 30 30 31 31 #import "PlatformString.h" 32 #import <wtf/text/CString.h> 32 33 33 34 namespace WebCore { … … 38 39 } 39 40 41 CString openTemporaryFile(const char* prefix, PlatformFileHandle& platformFileHandle) 42 { 43 platformFileHandle = invalidPlatformFileHandle; 44 45 Vector<char> temporaryFilePath(PATH_MAX); 46 if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryFilePath.data(), temporaryFilePath.size())) 47 return CString(); 48 49 // Shrink the vector. 50 temporaryFilePath.shrink(strlen(temporaryFilePath.data())); 51 ASSERT(temporaryFilePath.last() == '/'); 52 53 // Append the file name. 54 temporaryFilePath.append(prefix, strlen(prefix)); 55 temporaryFilePath.append("XXXXXX", 6); 56 temporaryFilePath.append('\0'); 57 58 platformFileHandle = mkstemp(temporaryFilePath.data()); 59 if (platformFileHandle == invalidPlatformFileHandle) 60 return CString(); 61 62 return CString(temporaryFilePath.data()); 63 } 64 40 65 } // namespace WebCore -
trunk/WebKit2/ChangeLog
r63701 r63704 1 2010-07-19 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Darin Adler, Adam Roben, Dan Bernstein and Sam Weinig. 4 5 Handle NP_ASFILE and NP_ASFILEONLY transfer modes 6 https://bugs.webkit.org/show_bug.cgi?id=42587 7 8 * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: 9 (WebKit::NetscapePlugin::NPP_StreamAsFile): 10 * WebProcess/Plugins/Netscape/NetscapePlugin.h: 11 Add NPP_ wrapper. 12 13 * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp: 14 (WebKit::NetscapePluginStream::NetscapePluginStream): 15 Initialize m_fileHandle. 16 17 (WebKit::isSupportedTransferMode): 18 NP_ASFILE and NP_ASFILEONLY is now supported. 19 20 (WebKit::NetscapePluginStream::deliverData): 21 Call deliverDataToFile if necessary. 22 23 (WebKit::NetscapePluginStream::deliverDataToFile): 24 Create a temporary file and write the data into it. 25 26 (WebKit::NetscapePluginStream::stop): 27 If the transfer mode is either NP_ASFILE or NP_ASFILEONLY, make sure to 28 call NPP_StreamAsFile and close the file and delete it. 29 30 * WebProcess/Plugins/PluginView.cpp: 31 (WebKit::PluginView::cancelStreamLoad): 32 Keep a reference to the Stream since cancelling it will remove it from the map. 33 1 34 2010-07-19 Anders Carlsson <andersca@apple.com> 2 35 -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
r63701 r63704 191 191 } 192 192 193 void NetscapePlugin::NPP_StreamAsFile(NPStream* stream, const char* filename) 194 { 195 return m_pluginModule->pluginFuncs().asfile(&m_npp, stream, filename); 196 } 197 193 198 int32_t NetscapePlugin::NPP_WriteReady(NPStream* stream) 194 199 { -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
r63701 r63704 74 74 NPError NPP_NewStream(NPMIMEType, NPStream*, NPBool seekable, uint16_t* stype); 75 75 NPError NPP_DestroyStream(NPStream*, NPReason); 76 void NPP_StreamAsFile(NPStream*, const char* filename); 77 76 78 int32_t NPP_WriteReady(NPStream*); 77 79 int32_t NPP_Write(NPStream*, int32_t offset, int32_t len, void* buffer); -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
r63500 r63704 42 42 , m_transferMode(NP_NORMAL) 43 43 , m_offset(0) 44 , m_fileHandle(invalidPlatformFileHandle) 44 45 , m_isStarted(false) 45 46 #if !ASSERT_DISABLED … … 55 56 ASSERT(!m_isStarted); 56 57 ASSERT(!m_sendNotification || m_urlNotifyHasBeenCalled); 58 ASSERT(m_fileHandle == invalidPlatformFileHandle); 57 59 } 58 60 … … 128 130 { 129 131 switch (transferMode) { 132 case NP_ASFILEONLY: 133 case NP_ASFILE: 130 134 case NP_NORMAL: 131 135 return true; 132 // FIXME: We don't support streaming to files.133 case NP_ASFILEONLY:134 case NP_ASFILE:135 return false;136 136 // FIXME: We don't support seekable streams. 137 137 case NP_SEEK: … … 191 191 } 192 192 193 // FIXME: Deliver the data to a file as well if needed. 193 if (m_transferMode == NP_ASFILE || m_transferMode == NP_ASFILEONLY) 194 deliverDataToFile(bytes, length); 194 195 } 195 196 … … 245 246 if (m_stopStreamWhenDoneDelivering) 246 247 stop(NPRES_DONE); 248 } 249 } 250 251 void NetscapePluginStream::deliverDataToFile(const char* bytes, int length) 252 { 253 if (m_fileHandle == invalidPlatformFileHandle && m_filePath.isNull()) { 254 // Create a temporary file. 255 m_filePath = openTemporaryFile("WebKitPluginStream", m_fileHandle); 256 257 // We failed to open the file, stop the stream. 258 if (m_fileHandle == invalidPlatformFileHandle) { 259 stop(NPRES_NETWORK_ERR); 260 return; 261 } 262 } 263 264 if (!length) 265 return; 266 267 int byteCount = writeToFile(m_fileHandle, bytes, length); 268 if (byteCount != length) { 269 // This happens only rarely, when we are out of disk space or have a disk I/O error. 270 closeFile(m_fileHandle); 271 272 stop(NPRES_NETWORK_ERR); 247 273 } 248 274 } … … 265 291 m_deliveryData = 0; 266 292 m_deliveryDataTimer.stop(); 293 294 if (m_transferMode == NP_ASFILE || m_transferMode == NP_ASFILEONLY) { 295 if (reason == NPRES_DONE) { 296 // Ensure that the file is created. 297 deliverDataToFile(0, 0); 298 if (m_fileHandle != invalidPlatformFileHandle) 299 closeFile(m_fileHandle); 300 301 ASSERT(!m_filePath.isNull()); 302 303 m_plugin->NPP_StreamAsFile(&m_npStream, m_filePath.data()); 304 } else { 305 // Just close the file. 306 if (m_fileHandle != invalidPlatformFileHandle) 307 closeFile(m_fileHandle); 308 } 309 310 // Delete the file after calling NPP_StreamAsFile(), instead of in the destructor. It should be OK 311 // to delete the file here -- NPP_StreamAsFile() is always called immediately before NPP_DestroyStream() 312 // (the stream destruction function), so there can be no expectation that a plugin will read the stream 313 // file asynchronously after NPP_StreamAsFile() is called. 314 deleteFile(String::fromUTF8(m_filePath.data())); 315 m_filePath = CString(); 316 317 // NPP_StreamAsFile could call NPN_DestroyStream and destroy the stream. 318 if (!m_isStarted) 319 return; 320 } 267 321 268 322 // Set m_isStarted to false before calling NPP_DestroyStream in case NPP_DestroyStream calls NPN_DestroyStream. -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
r63612 r63704 28 28 29 29 #include "RunLoop.h" 30 #include <WebCore/FileSystem.h> 30 31 #include <WebCore/npapi.h> 31 32 #include <wtf/PassRefPtr.h> … … 76 77 void deliverData(const char* bytes, int length); 77 78 void deliverDataToPlugin(); 79 void deliverDataToFile(const char* bytes, int length); 78 80 79 81 RefPtr<NetscapePlugin> m_plugin; … … 87 89 int32_t m_offset; 88 90 91 CString m_filePath; 92 WebCore::PlatformFileHandle m_fileHandle; 93 89 94 // Whether NPP_NewStream has successfully been called. 90 95 bool m_isStarted; -
trunk/WebKit2/WebProcess/Plugins/PluginView.cpp
r63701 r63704 372 372 373 373 // This request is to load a URL and create a stream. 374 RefPtr< PluginView::Stream> stream = PluginView::Stream::create(this, request->requestID(), request->request());374 RefPtr<Stream> stream = PluginView::Stream::create(this, request->requestID(), request->request()); 375 375 addStream(stream.get()); 376 376 stream->start(); … … 537 537 void PluginView::cancelStreamLoad(uint64_t streamID) 538 538 { 539 PluginView::Stream* stream = m_streams.get(streamID).get(); 539 // Keep a reference to the stream. Stream::cancel might remove the stream from the map, and thus 540 // releasing its last reference. 541 RefPtr<Stream> stream = m_streams.get(streamID).get(); 540 542 if (!stream) 541 543 return; 542 544 545 // Cancelling the stream here will remove it from the map. 543 546 stream->cancel(); 544 removeStream(stream);547 ASSERT(!m_streams.contains(streamID)); 545 548 } 546 549
Note: See TracChangeset
for help on using the changeset viewer.