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

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

Issue 14472008: [FileAPI] Add file open ID and close callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chromeos part Created 7 years, 8 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
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 d735e312d8e7da80effd8068bcb697c98ca26f8f..1d11b4f28049443147b3b7fa757d1b62ec5b43df 100644
--- a/content/browser/fileapi/fileapi_message_filter.cc
+++ b/content/browser/fileapi/fileapi_message_filter.cc
@@ -67,7 +67,8 @@ FileAPIMessageFilter::FileAPIMessageFilter(
context_(file_system_context),
request_context_getter_(request_context_getter),
request_context_(NULL),
- blob_storage_context_(blob_storage_context) {
+ blob_storage_context_(blob_storage_context),
+ next_file_open_id_(1) {
DCHECK(context_);
DCHECK(request_context_getter_);
DCHECK(blob_storage_context);
@@ -111,19 +112,15 @@ void FileAPIMessageFilter::OnChannelClosing() {
in_transit_snapshot_files_.clear();
// Close all files that are previously OpenFile()'ed in this process.
- if (!open_filesystem_urls_.empty()) {
+ if (!close_file_callbacks_.empty()) {
DLOG(INFO)
<< "File API: Renderer process shut down before NotifyCloseFile"
- << " for " << open_filesystem_urls_.size() << " files opened in PPAPI";
+ << " for " << close_file_callbacks_.size() << " files opened in PPAPI";
}
- for (std::multiset<GURL>::const_iterator iter =
- open_filesystem_urls_.begin();
- iter != open_filesystem_urls_.end(); ++iter) {
- FileSystemURL url(context_->CrackURL(*iter));
- FileSystemOperation* operation = context_->CreateFileSystemOperation(
- url, NULL);
- if (operation)
- operation->NotifyCloseFile(url);
+ for (std::map<int, base::Closure>::const_iterator iter =
+ close_file_callbacks_.begin();
+ iter != close_file_callbacks_.end(); ++iter) {
+ iter->second.Run();
}
}
@@ -460,23 +457,18 @@ void FileAPIMessageFilter::OnOpenFile(
base::Bind(&FileAPIMessageFilter::DidOpenFile, this, request_id, path));
}
-void FileAPIMessageFilter::OnNotifyCloseFile(const GURL& path) {
+void FileAPIMessageFilter::OnNotifyCloseFile(int file_open_id) {
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(context_->CrackURL(path));
+ std::map<int, base::Closure>::iterator itr =
+ close_file_callbacks_.find(file_open_id);
+ DCHECK(itr != close_file_callbacks_.end());
+ base::Closure callback = itr->second;
+ close_file_callbacks_.erase(itr);
- // Do not use GetNewOperation() here, because NotifyCloseFile is a one-way
- // operation that does not have request_id by which we respond back.
- FileSystemOperation* operation = context_->CreateFileSystemOperation(
- url, NULL);
- if (operation)
- operation->NotifyCloseFile(url);
+ callback.Run();
}
void FileAPIMessageFilter::OnWillUpdate(const GURL& path) {
@@ -657,13 +649,15 @@ void FileAPIMessageFilter::DidOpenFile(int request_id,
const GURL& path,
base::PlatformFileError result,
base::PlatformFile file,
+ const base::Closure& close_callback,
base::ProcessHandle peer_handle) {
if (result == base::PLATFORM_FILE_OK) {
IPC::PlatformFileForTransit file_for_transit =
file != base::kInvalidPlatformFileValue ?
IPC::GetFileHandleForProcess(file, peer_handle, true) :
IPC::InvalidPlatformFileForTransit();
- open_filesystem_urls_.insert(path);
+ int file_open_id = next_file_open_id_++;
+ close_file_callbacks_[file_open_id] = close_callback;
quota::QuotaLimitType quota_policy = quota::kQuotaLimitTypeUnknown;
quota::QuotaManagerProxy* quota_manager_proxy =
@@ -680,6 +674,7 @@ void FileAPIMessageFilter::DidOpenFile(int request_id,
Send(new FileSystemMsg_DidOpenFile(request_id,
file_for_transit,
+ file_open_id,
quota_policy));
} else {
Send(new FileSystemMsg_DidFail(request_id,

Powered by Google App Engine
This is Rietveld 408576698