Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: content/browser/fileapi/fileapi_message_filter.cc

Issue 10541113: Notify CloseFile from Pepper to FileSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/fileapi/fileapi_message_filter.h ('k') | content/common/fileapi/file_system_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/fileapi/fileapi_message_filter.cc
diff --git a/content/browser/fileapi/fileapi_message_filter.cc b/content/browser/fileapi/fileapi_message_filter.cc
index 2d7ec3f9ac00be2336c3d6557dc129036f78ff80..206cb0ccaaa347a3b2ba241d4bebc73bceff1288 100644
--- a/content/browser/fileapi/fileapi_message_filter.cc
+++ b/content/browser/fileapi/fileapi_message_filter.cc
@@ -120,6 +120,21 @@ void FileAPIMessageFilter::OnChannelClosing() {
iter != blob_urls_.end(); ++iter) {
blob_storage_context_->controller()->RemoveBlob(GURL(*iter));
}
+
+ // Close all files that are previously OpenFile()'ed in this process.
+ if (!open_filesystem_urls_.empty()) {
+ DLOG(INFO)
+ << "File API: Renderer process shut down before NotifyCloseFile"
+ << " for " << open_filesystem_urls_.size() << " files opened in PPAPI";
+ }
+ for (std::multiset<GURL>::const_iterator iter =
+ open_filesystem_urls_.begin();
+ iter != open_filesystem_urls_.end(); ++iter) {
+ FileSystemURL url(*iter);
+ FileSystemOperationInterface* operation =
+ context_->CreateFileSystemOperation(url);
+ operation->NotifyCloseFile(url);
+ }
}
void FileAPIMessageFilter::OverrideThreadForMessage(
@@ -147,6 +162,7 @@ bool FileAPIMessageFilter::OnMessageReceived(
IPC_MESSAGE_HANDLER(FileSystemHostMsg_TouchFile, OnTouchFile)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_CancelWrite, OnCancel)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_OpenFile, OnOpenFile)
+ IPC_MESSAGE_HANDLER(FileSystemHostMsg_NotifyCloseFile, OnNotifyCloseFile)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_CreateSnapshotFile,
OnCreateSnapshotFile)
IPC_MESSAGE_HANDLER(FileSystemHostMsg_WillUpdate, OnWillUpdate)
@@ -404,7 +420,26 @@ void FileAPIMessageFilter::OnOpenFile(
GetNewOperation(url, request_id)->OpenFile(
url, file_flags, peer_handle(),
- base::Bind(&FileAPIMessageFilter::DidOpenFile, this, request_id));
+ base::Bind(&FileAPIMessageFilter::DidOpenFile, this, request_id, path));
+}
+
+void FileAPIMessageFilter::OnNotifyCloseFile(const GURL& path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ // Remove |path| from the set of opened urls. It must only be called for a URL
+ // that is successfully opened and enrolled in DidOpenFile.
+ std::multiset<GURL>::iterator iter = open_filesystem_urls_.find(path);
+ DCHECK(iter != open_filesystem_urls_.end());
+ open_filesystem_urls_.erase(iter);
+
+ FileSystemURL url(path);
+
+ // Do not use GetNewOperation() here, because NotifyCloseFile is a one-way
+ // operation that does not have request_id by which we respond back.
+ FileSystemOperationInterface* operation =
+ context_->CreateFileSystemOperation(url);
+ if (operation)
+ operation->NotifyCloseFile(url);
}
void FileAPIMessageFilter::OnWillUpdate(const GURL& path) {
@@ -569,6 +604,7 @@ void FileAPIMessageFilter::DidReadDirectory(
}
void FileAPIMessageFilter::DidOpenFile(int request_id,
+ const GURL& path,
base::PlatformFileError result,
base::PlatformFile file,
base::ProcessHandle peer_handle) {
@@ -577,6 +613,7 @@ void FileAPIMessageFilter::DidOpenFile(int request_id,
file != base::kInvalidPlatformFileValue ?
IPC::GetFileHandleForProcess(file, peer_handle, true) :
IPC::InvalidPlatformFileForTransit();
+ open_filesystem_urls_.insert(path);
Send(new FileSystemMsg_DidOpenFile(request_id, file_for_transit));
} else {
Send(new FileSystemMsg_DidFail(request_id, result));
« no previous file with comments | « content/browser/fileapi/fileapi_message_filter.h ('k') | content/common/fileapi/file_system_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698