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

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

Issue 131082: Add getFileSize support to chromium... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/chrome.gyp » ('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 19855)
+++ chrome/browser/renderer_host/resource_message_filter.cc (working copy)
@@ -10,6 +10,7 @@
#include "base/histogram.h"
#include "base/process_util.h"
#include "base/thread.h"
+#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/chrome_plugin_browsing_context.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extension_message_service.h"
@@ -19,6 +20,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/audio_renderer_host.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
+#include "chrome/browser/renderer_host/file_system_accessor.h"
#include "chrome/browser/renderer_host/render_widget_helper.h"
#include "chrome/browser/spellchecker.h"
#include "chrome/browser/worker_host/worker_service.h"
@@ -323,6 +325,8 @@
OnCloseIdleConnections)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode,
OnSetCacheMode)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize,
+ OnGetFileSize)
IPC_MESSAGE_UNHANDLED(
handled = false)
@@ -913,3 +917,31 @@
net::HttpCache::NORMAL : net::HttpCache::DISABLE;
request_context_->http_transaction_factory()->GetCache()->set_mode(mode);
}
+
+void ResourceMessageFilter::OnGetFileSize(const FilePath& path,
+ IPC::Message* reply_msg) {
+ // Increase the ref count to ensure ResourceMessageFilter won't be destroyed
+ // before GetFileSize callback is done.
+ AddRef();
+
+ // Get file size only when the child process has been granted permission to
+ // upload the file.
+ if (ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(
+ render_process_id_, path)) {
+ FileSystemAccessor::RequestFileSize(
+ path,
+ reply_msg,
+ NewCallback(this, &ResourceMessageFilter::ReplyGetFileSize));
+ } else {
+ ReplyGetFileSize(-1, reply_msg);
+ }
+}
+
+void ResourceMessageFilter::ReplyGetFileSize(int64 result, void* param) {
+ IPC::Message* reply_msg = static_cast<IPC::Message*>(param);
+ ViewHostMsg_GetFileSize::WriteReplyParams(reply_msg, result);
+ Send(reply_msg);
+
+ // Getting file size callback done, decrease the ref count.
+ Release();
+}
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698