Commit b63a48bb authored by michaeln@google.com's avatar michaeln@google.com

FileSystem mods: Remove some dead snapshot creation code.

This CL is the 4th in a series of changes that straddle webkit vs chromium repositories.
1) WK: Declare new virtual createSnapshotFile/didCreateSnapshotFile public api methods.
2) CR: Implement the new create method such that the didCreate method is invoked in response.
3) WK: Use the new create method and implement the new didCreate method.
4) CR: Cleanup the obsolete/deprecated blocks of code.

BUG=174200

Review URL: https://codereview.chromium.org/13891009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194648 0039d316-1c4b-4281-b951-d872f2087c98
parent 40bc3099
......@@ -158,8 +158,6 @@ bool FileAPIMessageFilter::OnMessageReceived(
OnCreateSnapshotFile)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_DidReceiveSnapshotFile,
OnDidReceiveSnapshotFile)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_CreateSnapshotFile_Deprecated,
OnCreateSnapshotFile_Deprecated)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_WillUpdate, OnWillUpdate)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_DidUpdate, OnDidUpdate)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_SyncGetPlatformPath,
......@@ -539,32 +537,6 @@ void FileAPIMessageFilter::OnDidReceiveSnapshotFile(int request_id) {
in_transit_snapshot_files_.erase(request_id);
}
void FileAPIMessageFilter::OnCreateSnapshotFile_Deprecated(
int request_id, const GURL& blob_url, const GURL& path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
FileSystemURL url(context_->CrackURL(path));
base::Callback<void(const base::FilePath&)> register_file_callback =
base::Bind(&FileAPIMessageFilter::RegisterFileAsBlob,
this, blob_url, url);
// Make sure if this file can be read by the renderer as this is
// called when the renderer is about to create a new File object
// (for reading the file).
base::PlatformFileError error;
if (!HasPermissionsForFile(url, fileapi::kReadFilePermissions, &error)) {
Send(new FileSystemMsg_DidFail(request_id, error));
return;
}
FileSystemOperation* operation = GetNewOperation(url, request_id);
if (!operation)
return;
operation->CreateSnapshotFile(
url,
base::Bind(&FileAPIMessageFilter::DidCreateSnapshot_Deprecated,
this, request_id, register_file_callback));
}
void FileAPIMessageFilter::OnStartBuildingBlob(const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
blob_storage_context_->controller()->StartBuildingBlob(url);
......@@ -806,80 +778,6 @@ void FileAPIMessageFilter::DidCreateSnapshot(
request_id, info, platform_path));
}
void FileAPIMessageFilter::DidCreateSnapshot_Deprecated(
int request_id,
const base::Callback<void(const base::FilePath&)>& register_file_callback,
base::PlatformFileError result,
const base::PlatformFileInfo& info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& unused) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (result != base::PLATFORM_FILE_OK) {
Send(new FileSystemMsg_DidFail(request_id, result));
return;
}
// Register the created file to the blob registry by calling
// RegisterFileAsBlob.
// Blob storage automatically finds and refs the file_ref, so we don't
// need to do anything for the returned file reference (|unused|) here.
register_file_callback.Run(platform_path);
// Return the file info and platform_path.
Send(new FileSystemMsg_DidReadMetadata(request_id, info, platform_path));
}
void FileAPIMessageFilter::RegisterFileAsBlob(
const GURL& blob_url,
const FileSystemURL& url,
const base::FilePath& platform_path) {
// Use the virtual path's extension to determine MIME type.
base::FilePath::StringType extension = url.path().Extension();
if (!extension.empty())
extension = extension.substr(1); // Strip leading ".".
scoped_refptr<webkit_blob::ShareableFileReference> shareable_file =
webkit_blob::ShareableFileReference::Get(platform_path);
if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
process_id_, platform_path)) {
// In order for the renderer to be able to read the file, it must be granted
// read permission for the file's platform path. By now, it has already been
// verified that the renderer has sufficient permissions to read the file.
// It is still possible that ChildProcessSecurityPolicyImpl doesn't reflect
// that the renderer can read the file's platform path. If this is the case
// the renderer should be granted read permission for the file's platform
// path. This can happen in the following situations:
// - the file comes from sandboxed filesystem. Reading sandboxed files is
// always permitted, but only implicitly.
// - the underlying filesystem returned newly created snapshot file.
// - the file comes from an external drive filesystem. The renderer has
// already been granted read permission for the file's nominal path, but
// for drive files, platform paths differ from the nominal paths.
DCHECK(shareable_file ||
fileapi::SandboxMountPointProvider::CanHandleType(url.type()) ||
url.type() == fileapi::kFileSystemTypeDrive);
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
process_id_, platform_path);
if (shareable_file) {
// This will revoke all permissions for the file when the last ref
// of the file is dropped (assuming it's ok).
shareable_file->AddFinalReleaseCallback(
base::Bind(&RevokeFilePermission, process_id_));
}
}
// This may fail, but then we'll be just setting the empty mime type.
std::string mime_type;
net::GetWellKnownMimeTypeFromExtension(extension, &mime_type);
BlobData::Item item;
item.SetToFilePathRange(platform_path, 0, -1, base::Time());
BlobStorageController* controller = blob_storage_context_->controller();
controller->StartBuildingBlob(blob_url);
controller->AppendBlobDataItem(blob_url, item);
controller->FinishBuildingBlob(blob_url, mime_type);
blob_urls_.insert(blob_url.spec());
}
bool FileAPIMessageFilter::HasPermissionsForFile(
const FileSystemURL& url, int permissions, base::PlatformFileError* error) {
return CheckFileSystemPermissionsForProcess(context_, process_id_, url,
......
......@@ -119,10 +119,6 @@ class FileAPIMessageFilter : public BrowserMessageFilter {
const GURL& path);
void OnDidReceiveSnapshotFile(int request_id);
void OnCreateSnapshotFile_Deprecated(int request_id,
const GURL& blob_url,
const GURL& path);
void OnStartBuildingBlob(const GURL& url);
void OnAppendBlobDataItem(const GURL& url,
const webkit_blob::BlobData::Item& item);
......@@ -166,19 +162,6 @@ class FileAPIMessageFilter : public BrowserMessageFilter {
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
void DidCreateSnapshot_Deprecated(
int request_id,
const base::Callback<void(const base::FilePath&)>& register_file_callback,
base::PlatformFileError result,
const base::PlatformFileInfo& info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
// Registers the given file pointed by |virtual_path| and backed by
// |platform_path| as the |blob_url|. Called by DidCreateSnapshot_Deprecated.
void RegisterFileAsBlob(const GURL& blob_url,
const fileapi::FileSystemURL& url,
const base::FilePath& platform_path);
// Checks renderer's access permissions for single file.
bool HasPermissionsForFile(const fileapi::FileSystemURL& url,
int permissions,
......
......@@ -265,20 +265,6 @@ bool FileSystemDispatcher::CreateSnapshotFile(
return true;
}
bool FileSystemDispatcher::CreateSnapshotFile_Deprecated(
const GURL& blob_url,
const GURL& file_path,
fileapi::FileSystemCallbackDispatcher* dispatcher) {
int request_id = dispatchers_.Add(dispatcher);
if (!ChildThread::current()->Send(
new FileSystemHostMsg_CreateSnapshotFile_Deprecated(
request_id, blob_url, file_path))) {
dispatchers_.Remove(request_id); // destroys |dispatcher|
return false;
}
return true;
}
void FileSystemDispatcher::OnDidOpenFileSystem(int request_id,
const std::string& name,
const GURL& root) {
......
......@@ -95,11 +95,6 @@ class FileSystemDispatcher : public IPC::Listener {
bool CreateSnapshotFile(const GURL& file_path,
fileapi::FileSystemCallbackDispatcher* dispatcher);
bool CreateSnapshotFile_Deprecated(
const GURL& blod_url,
const GURL& file_path,
fileapi::FileSystemCallbackDispatcher* dispatcher);
private:
// Message handlers.
void OnDidOpenFileSystem(int request_id,
......
......@@ -150,12 +150,6 @@ IPC_MESSAGE_CONTROL3(FileSystemHostMsg_OpenFile,
IPC_MESSAGE_CONTROL1(FileSystemHostMsg_NotifyCloseFile,
GURL /* file path */)
// DEPRECATED
IPC_MESSAGE_CONTROL3(FileSystemHostMsg_CreateSnapshotFile_Deprecated,
int /* request_id */,
GURL /* blob_url */,
GURL /* file_path */)
// WebFileSystem::createSnapshotFileAndReadMetadata() message.
IPC_MESSAGE_CONTROL2(FileSystemHostMsg_CreateSnapshotFile,
int /* request_id */,
......
......@@ -128,16 +128,4 @@ void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
GURL(path), new WebFileSystemCallbackDispatcher(callbacks));
}
// DEPRECATED
void WebFileSystemImpl::createSnapshotFileAndReadMetadata(
const WebKit::WebURL& blobURL,
const WebKit::WebURL& path,
WebKit::WebFileSystemCallbacks* callbacks) {
FileSystemDispatcher* dispatcher =
ChildThread::current()->file_system_dispatcher();
dispatcher->CreateSnapshotFile_Deprecated(
GURL(blobURL), GURL(path),
new WebFileSystemCallbackDispatcher(callbacks));
}
} // namespace content
......@@ -62,12 +62,6 @@ class WebFileSystemImpl : public WebKit::WebFileSystem {
virtual void createSnapshotFileAndReadMetadata(
const WebKit::WebURL& path,
WebKit::WebFileSystemCallbacks*);
// DEPRECATED variant being replaced by the above.
virtual void createSnapshotFileAndReadMetadata(
const WebKit::WebURL& blobURL,
const WebKit::WebURL& path,
WebKit::WebFileSystemCallbacks*);
};
} // namespace content
......
......@@ -254,20 +254,6 @@ void SimpleFileSystem::createSnapshotFileAndReadMetadata(
url, SnapshotFileHandler(callbacks));
}
// DEPRECATED
void SimpleFileSystem::createSnapshotFileAndReadMetadata(
const WebURL& blobURL,
const WebURL& path,
WebFileSystemCallbacks* callbacks) {
FileSystemURL url(file_system_context()->CrackURL(path));
if (!HasFilePermission(url, fileapi::kReadFilePermissions)) {
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
GetNewOperation(url)->CreateSnapshotFile(
url, SnapshotFileHandler_Deprecated(blobURL, callbacks));
}
// static
void SimpleFileSystem::InitializeOnIOThread(
webkit_blob::BlobStorageController* blob_storage_controller) {
......@@ -336,14 +322,6 @@ SimpleFileSystem::SnapshotFileHandler(
AsWeakPtr(), base::Unretained(callbacks));
}
FileSystemOperation::SnapshotFileCallback
SimpleFileSystem::SnapshotFileHandler_Deprecated(
const GURL& blob_url,
WebFileSystemCallbacks* callbacks) {
return base::Bind(&SimpleFileSystem::DidCreateSnapshotFile_Deprecated,
AsWeakPtr(), blob_url, base::Unretained(callbacks));
}
void SimpleFileSystem::DidFinish(WebFileSystemCallbacks* callbacks,
base::PlatformFileError result) {
if (result == base::PLATFORM_FILE_OK)
......@@ -433,19 +411,3 @@ void SimpleFileSystem::DidCreateSnapshotFile(
callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
}
}
void SimpleFileSystem::DidCreateSnapshotFile_Deprecated(
const GURL& blob_url,
WebFileSystemCallbacks* callbacks,
base::PlatformFileError result,
const base::PlatformFileInfo& info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
DCHECK(g_io_thread);
if (result == base::PLATFORM_FILE_OK) {
g_io_thread->PostTask(
FROM_HERE,
base::Bind(&RegisterBlob, blob_url, platform_path));
}
DidGetMetadata(callbacks, result, info, platform_path);
}
......@@ -92,12 +92,6 @@ class SimpleFileSystem
const WebKit::WebURL& path,
WebKit::WebFileSystemCallbacks* callbacks);
// DEPRECATED
virtual void createSnapshotFileAndReadMetadata(
const WebKit::WebURL& blobURL,
const WebKit::WebURL& path,
WebKit::WebFileSystemCallbacks* callbacks);
static void InitializeOnIOThread(
webkit_blob::BlobStorageController* blob_storage_controller);
static void CleanupOnIOThread();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment