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

Unified Diff: content/browser/renderer_host/file_utilities_message_filter.cc

Issue 10441016: Add FileUtilities::GetFileInfo() to capture file metadata with single IPC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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/renderer_host/file_utilities_message_filter.cc
diff --git a/content/browser/renderer_host/file_utilities_message_filter.cc b/content/browser/renderer_host/file_utilities_message_filter.cc
index e72916cde00582316531f63c31951cc34c500f73..0f8370aca6021d88304d56da2bdf24664b9ce129 100644
--- a/content/browser/renderer_host/file_utilities_message_filter.cc
+++ b/content/browser/renderer_host/file_utilities_message_filter.cc
@@ -31,6 +31,7 @@ bool FileUtilitiesMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileSize, OnGetFileSize)
IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileModificationTime,
OnGetFileModificationTime)
+ IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileInfo, OnGetFileInfo)
IPC_MESSAGE_HANDLER(FileUtilitiesMsg_OpenFile, OnOpenFile)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -71,6 +72,24 @@ void FileUtilitiesMessageFilter::OnGetFileModificationTime(
*result = file_info.last_modified;
}
+void FileUtilitiesMessageFilter::OnGetFileInfo(
+ const FilePath& path,
+ base::PlatformFileInfo* result,
+ base::PlatformFileError* status) {
+ *result = base::PlatformFileInfo();
+ *status = base::PLATFORM_FILE_OK;
+
+ // Get file metadata only when the child process has been granted
+ // permission to read the file.
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
+ process_id_, path)) {
+ return;
+ }
+
+ if (!file_util::GetFileInfo(path, result))
+ *status = base::PLATFORM_FILE_ERROR_FAILED;
+}
+
void FileUtilitiesMessageFilter::OnOpenFile(
const FilePath& path,
int mode,
« no previous file with comments | « content/browser/renderer_host/file_utilities_message_filter.h ('k') | content/common/file_utilities_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698