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 5258fbffd541a9015b580ed36a18ee9c8c53a99d..3e0496accf5d4546c3a54d447f82f77553f12a11 100644 |
--- a/content/browser/fileapi/fileapi_message_filter.cc |
+++ b/content/browser/fileapi/fileapi_message_filter.cc |
@@ -119,6 +119,17 @@ 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. |
+ for (base::hash_set<std::string>::const_iterator iter = |
+ open_filesystem_urls_.begin(); |
+ iter != open_filesystem_urls_.end(); ++iter) { |
+ GURL url(*iter); |
+ FileSystemOperationInterface* operation = |
+ context_->CreateFileSystemOperation(url); |
+ if (operation) |
+ operation->NotifyCloseFile(url); |
+ } |
} |
void FileAPIMessageFilter::OverrideThreadForMessage( |
@@ -146,6 +157,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) |
@@ -390,7 +402,23 @@ void FileAPIMessageFilter::OnOpenFile( |
GetNewOperation(path, request_id)->OpenFile( |
path, 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. If it is not contained, |
+ // returns immediately. |
+ if (open_filesystem_urls_.erase(path.spec()) == 0) |
kinuko
2012/06/25 11:46:54
How could this happen? Do we want to assert here?
kinaba
2012/06/26 00:15:10
It should never happen as long as it is correctly
|
+ return; |
+ |
+ // Do not use GetNewOperation() here, because NotifyCloseFile is an one-way |
+ // operation that does not |
kinuko
2012/06/25 11:46:54
nit: that does not ...?
kinaba
2012/06/26 00:15:10
:)
|
+ FileSystemOperationInterface* operation = |
+ context_->CreateFileSystemOperation(path); |
+ if (operation) |
+ operation->NotifyCloseFile(path); |
} |
void FileAPIMessageFilter::OnWillUpdate(const GURL& path) { |
@@ -561,6 +589,7 @@ void FileAPIMessageFilter::DidReadDirectory( |
} |
void FileAPIMessageFilter::DidOpenFile(int request_id, |
+ const GURL& path, |
base::PlatformFileError result, |
base::PlatformFile file, |
base::ProcessHandle peer_handle) { |
@@ -569,6 +598,7 @@ void FileAPIMessageFilter::DidOpenFile(int request_id, |
file != base::kInvalidPlatformFileValue ? |
IPC::GetFileHandleForProcess(file, peer_handle, true) : |
IPC::InvalidPlatformFileForTransit(); |
+ open_filesystem_urls_.insert(path.spec()); |
Send(new FileSystemMsg_DidOpenFile(request_id, file_for_transit)); |
} else { |
Send(new FileSystemMsg_DidFail(request_id, result)); |