Make BlobDataFileReference manage its sandbox extension
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 May 2014 18:33:18 +0000 (18:33 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 May 2014 18:33:18 +0000 (18:33 +0000)
commit990c099f042c58035f2a72797c2504f4b74b3d72
tree5c6cf7a7561ac7ecd036079adf348c3f7248d531
parent28fb07de384c2d1e60c12ca4b89bffb0c0472be7
Make BlobDataFileReference manage its sandbox extension
https://bugs.webkit.org/show_bug.cgi?id=132689

Reviewed by Anders Carlsson.

Source/WebCore:
* WebCore.exp.in: Export symbols that are now needed in WebKit2 to subclass BlobDataFileReference.

* fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL):
* platform/network/BlobData.cpp: (WebCore::BlobData::appendFile):
* platform/network/BlobData.h: (WebCore::BlobDataItem::BlobDataItem):
* platform/network/BlobRegistry.h:
* platform/network/BlobRegistryImpl.cpp: (WebCore::BlobRegistryImpl::registerFileBlobURL):
* platform/network/BlobRegistryImpl.h:
BlobRegistry now takes a BlobDataFileReference and not a path, so that WebKit2
could pass objects that include sandbox extensions.

* platform/network/BlobDataFileReference.h:
* platform/network/BlobDataFileReference.cpp:
(WebCore::BlobDataFileReference::~BlobDataFileReference): Added a virtual destructor.
(WebCore::BlobDataFileReference::size): We now record the size and modification time right away, no need to lazily calculate them.
(WebCore::BlobDataFileReference::expectedModificationTime): Ditto.
(WebCore::BlobDataFileReference::startTrackingModifications): Record time and size
(since it's a single call). However, size calculation will become complicated again soon.
(WebCore::BlobDataFileReference::prepareForFileAccess): A hook for subclasses.
(WebCore::BlobDataFileReference::revokeFileAccess): Ditto.
(WebCore::BlobDataFileReference::computeFileSystemData): Deleted.

Source/WebKit2:
* CMakeLists.txt:
* PlatformGTK.cmake:
* WebKit2.xcodeproj/project.pbxproj:
Added BlobDataFileReferenceWithSandboxExtension.

* NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
(WebKit::NetworkBlobRegistry::registerFileBlobURL):
(WebKit::NetworkBlobRegistry::registerBlobURL):
(WebKit::NetworkBlobRegistry::registerBlobURLForSlice):
(WebKit::NetworkBlobRegistry::unregisterBlobURL):
(WebKit::NetworkBlobRegistry::connectionToWebProcessDidClose):
(WebKit::NetworkBlobRegistry::filesInBlob):
(WebKit::NetworkBlobRegistry::sandboxExtensions): Deleted.
* NetworkProcess/FileAPI/NetworkBlobRegistry.h:
We no longer track sandbox extensions here. Instead, provide a way to get files
for a blob, which contain extensions and can allow access to themselves.

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::NetworkResourceLoader):
(WebKit::NetworkResourceLoader::consumeSandboxExtensions):
(WebKit::NetworkResourceLoader::invalidateSandboxExtensions):
* NetworkProcess/NetworkResourceLoader.h:
Allow/revoke access to files in blob, just like we do for explicitly passed extensions.

* Shared/BlobDataFileReferenceWithSandboxExtension.cpp: Added.
(WebKit::BlobDataFileReferenceWithSandboxExtension::BlobDataFileReferenceWithSandboxExtension):
(WebKit::BlobDataFileReferenceWithSandboxExtension::~BlobDataFileReferenceWithSandboxExtension):
(WebKit::BlobDataFileReferenceWithSandboxExtension::prepareForFileAccess):
(WebKit::BlobDataFileReferenceWithSandboxExtension::revokeFileAccess):
* Shared/BlobDataFileReferenceWithSandboxExtension.h: Added.
(WebKit::BlobDataFileReferenceWithSandboxExtension::create):
A subclass of BlobDataFileReference that also contains a sandbox extension. NetworkProcess
always uses it in BlobRegistryImpl.

* WebProcess/FileAPI/BlobRegistryProxy.cpp: (WebKit::BlobRegistryProxy::registerFileBlobURL):
* WebProcess/FileAPI/BlobRegistryProxy.h:
Updated for BlobRegistry interface changes. BlobRegistryProxy doesn't really need
a BlobDataFileReference here, as it only uses a path, but it needs to implement the same interface
as BlobRegistryImpl.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168478 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
Source/WebCore/platform/network/BlobData.cpp
Source/WebCore/platform/network/BlobData.h
Source/WebCore/platform/network/BlobDataFileReference.cpp
Source/WebCore/platform/network/BlobDataFileReference.h
Source/WebCore/platform/network/BlobRegistry.h
Source/WebCore/platform/network/BlobRegistryImpl.cpp
Source/WebCore/platform/network/BlobRegistryImpl.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp
Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.cpp [new file with mode: 0644]
Source/WebKit2/Shared/BlobDataFileReferenceWithSandboxExtension.h [new file with mode: 0644]
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp
Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h