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

Unified Diff: chrome/browser/renderer_host/resource_message_filter.cc

Issue 594036: Support sending a sliced file in chromium.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/common_param_traits.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/resource_message_filter.cc
===================================================================
--- chrome/browser/renderer_host/resource_message_filter.cc (revision 42417)
+++ chrome/browser/renderer_host/resource_message_filter.cc (working copy)
@@ -265,6 +265,17 @@
scoped_refptr<URLRequestContext> context_;
};
+void WriteFileSize(IPC::Message* reply_msg,
+ const file_util::FileInfo& file_info) {
+ ViewHostMsg_GetFileSize::WriteReplyParams(reply_msg, file_info.size);
+}
+
+void WriteFileModificationTime(IPC::Message* reply_msg,
+ const file_util::FileInfo& file_info) {
+ ViewHostMsg_GetFileModificationTime::WriteReplyParams(
+ reply_msg, file_info.last_modified);
+}
+
} // namespace
ResourceMessageFilter::ResourceMessageFilter(
@@ -520,6 +531,8 @@
OnCloseCurrentConnections)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode, OnSetCacheMode)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime,
+ OnGetFileModificationTime)
IPC_MESSAGE_HANDLER(ViewHostMsg_Keygen, OnKeygen)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetExtensionMessageBundle,
OnGetExtensionMessageBundle)
@@ -1318,19 +1331,42 @@
ChromeThread::PostTask(
ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(
- this, &ResourceMessageFilter::OnGetFileSizeOnFileThread, path,
- reply_msg));
+ this, &ResourceMessageFilter::OnGetFileInfoOnFileThread, path,
+ reply_msg, &WriteFileSize));
}
-void ResourceMessageFilter::OnGetFileSizeOnFileThread(
- const FilePath& path, IPC::Message* reply_msg) {
+void ResourceMessageFilter::OnGetFileModificationTime(const FilePath& path,
+ IPC::Message* reply_msg) {
+ // Get file modification time only when the child process has been granted
+ // permission to upload the file.
+ if (!ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(id(), path)) {
+ ViewHostMsg_GetFileModificationTime::WriteReplyParams(reply_msg,
+ base::Time());
+ Send(reply_msg);
+ return;
+ }
+
+ // Getting file modification time could take a long time if it lives on a
+ // network share, so run it on the FILE thread.
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::OnGetFileInfoOnFileThread,
+ path, reply_msg, &WriteFileModificationTime));
+}
+
+void ResourceMessageFilter::OnGetFileInfoOnFileThread(
+ const FilePath& path,
+ IPC::Message* reply_msg,
+ FileInfoWriteFunc write_func) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
- int64 result;
- if (!file_util::GetFileSize(path, &result))
- result = -1;
- ViewHostMsg_GetFileSize::WriteReplyParams(reply_msg, result);
+ file_util::FileInfo file_info;
+ file_info.size = 0;
+ file_util::GetFileInfo(path, &file_info);
+ (*write_func)(reply_msg, file_info);
+
ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg));
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/common_param_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698