summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chrome_plugin_host.cc3
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc52
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h11
-rw-r--r--chrome/common/common_param_traits.h7
-rw-r--r--chrome/common/render_messages_internal.h7
-rw-r--r--chrome/common/resource_dispatcher.cc13
-rw-r--r--chrome/plugin/chrome_plugin_host.cc6
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc15
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h2
-rw-r--r--chrome/renderer/translate/page_translator_unittest.cc7
10 files changed, 104 insertions, 19 deletions
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc
index 50d9abc..56d8828 100644
--- a/chrome/browser/chrome_plugin_host.cc
+++ b/chrome/browser/chrome_plugin_host.cc
@@ -656,7 +656,8 @@ CPError STDCALL CPR_AppendFileToUpload(CPRequest* request, const char* filepath,
if (!length) length = kuint64max;
FilePath path(FilePath::FromWStringHack(UTF8ToWide(filepath)));
- handler->request()->AppendFileRangeToUpload(path, offset, length);
+ handler->request()->AppendFileRangeToUpload(path, offset, length,
+ base::Time());
return CPERR_SUCCESS;
}
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 48c1cb6..de9e836 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -265,6 +265,17 @@ class GetRawCookiesCompletion : public net::CompletionCallback {
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 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
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,18 +1331,41 @@ void ResourceMessageFilter::OnGetFileSize(const FilePath& path,
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,
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index c903f6e..2abc4c0 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -48,6 +48,10 @@ class URLRequestContextGetter;
struct ViewHostMsg_CreateWorker_Params;
struct WebPluginInfo;
+namespace file_util {
+struct FileInfo;
+}
+
namespace printing {
class PrinterQuery;
class PrintJobManager;
@@ -122,6 +126,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
private:
friend class ChromeThread;
friend class DeleteTask<ResourceMessageFilter>;
+ typedef void (*FileInfoWriteFunc)(IPC::Message* reply_msg,
+ const file_util::FileInfo& file_info);
virtual ~ResourceMessageFilter();
@@ -306,7 +312,10 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnSetCacheMode(bool enabled);
void OnGetFileSize(const FilePath& path, IPC::Message* reply_msg);
- void OnGetFileSizeOnFileThread(const FilePath& path, IPC::Message* reply_msg);
+ void OnGetFileModificationTime(const FilePath& path, IPC::Message* reply_msg);
+ void OnGetFileInfoOnFileThread(const FilePath& path,
+ IPC::Message* reply_msg,
+ FileInfoWriteFunc write_func);
void OnKeygen(uint32 key_size_index, const std::string& challenge_string,
const GURL& url, std::string* signed_public_key);
void OnGetExtensionMessageBundle(const std::string& extension_id,
diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h
index 72f84ee..426075a 100644
--- a/chrome/common/common_param_traits.h
+++ b/chrome/common/common_param_traits.h
@@ -318,6 +318,7 @@ struct ParamTraits<net::UploadData::Element> {
WriteParam(m, p.file_path());
WriteParam(m, p.file_range_offset());
WriteParam(m, p.file_range_length());
+ WriteParam(m, p.expected_file_modification_time());
}
}
static bool Read(const Message* m, void** iter, param_type* r) {
@@ -334,13 +335,17 @@ struct ParamTraits<net::UploadData::Element> {
DCHECK(type == net::UploadData::TYPE_FILE);
FilePath file_path;
uint64 offset, length;
+ base::Time expected_modification_time;
if (!ReadParam(m, iter, &file_path))
return false;
if (!ReadParam(m, iter, &offset))
return false;
if (!ReadParam(m, iter, &length))
return false;
- r->SetToFilePathRange(file_path, offset, length);
+ if (!ReadParam(m, iter, &expected_modification_time))
+ return false;
+ r->SetToFilePathRange(file_path, offset, length,
+ expected_modification_time);
}
return true;
}
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index afc9a4c..a0f5d14 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -15,6 +15,7 @@
#include "base/file_path.h"
#include "base/nullable_string16.h"
#include "base/sync_socket.h"
+#include "base/time.h"
#include "base/values.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/extensions/update_manifest.h"
@@ -2101,6 +2102,12 @@ IPC_BEGIN_MESSAGES(ViewHost)
FilePath /* path */,
int64 /* result */)
+ // Get file modification time in seconds. Set result to 0 if failed to get the
+ // file modification time.
+ IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetFileModificationTime,
+ FilePath /* path */,
+ base::Time /* result */)
+
// Sent by the renderer process to acknowledge receipt of a
// ViewMsg_CSSInsertRequest message and css has been inserted into the frame.
IPC_MESSAGE_ROUTED0(ViewHostMsg_OnCSSInserted)
diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc
index 9df8eaf..5c2fd28 100644
--- a/chrome/common/resource_dispatcher.cc
+++ b/chrome/common/resource_dispatcher.cc
@@ -52,8 +52,11 @@ class IPCResourceLoaderBridge : public ResourceLoaderBridge {
// ResourceLoaderBridge
virtual void AppendDataToUpload(const char* data, int data_len);
- virtual void AppendFileRangeToUpload(const FilePath& path,
- uint64 offset, uint64 length);
+ virtual void AppendFileRangeToUpload(
+ const FilePath& path,
+ uint64 offset,
+ uint64 length,
+ const base::Time& expected_modification_time);
virtual void SetUploadIdentifier(int64 identifier);
virtual bool Start(Peer* peer);
virtual void Cancel();
@@ -152,12 +155,14 @@ void IPCResourceLoaderBridge::AppendDataToUpload(const char* data,
}
void IPCResourceLoaderBridge::AppendFileRangeToUpload(
- const FilePath& path, uint64 offset, uint64 length) {
+ const FilePath& path, uint64 offset, uint64 length,
+ const base::Time& expected_modification_time) {
DCHECK(request_id_ == -1) << "request already started";
if (!request_.upload_data)
request_.upload_data = new net::UploadData();
- request_.upload_data->AppendFileRange(path, offset, length);
+ request_.upload_data->AppendFileRange(path, offset, length,
+ expected_modification_time);
}
void IPCResourceLoaderBridge::SetUploadIdentifier(int64 identifier) {
diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc
index 4561cc4..b3ae0ec 100644
--- a/chrome/plugin/chrome_plugin_host.cc
+++ b/chrome/plugin/chrome_plugin_host.cc
@@ -147,7 +147,8 @@ class PluginRequestHandlerProxy
void AppendFileRangeToUpload(const FilePath &filepath,
uint64 offset, uint64 length) {
upload_content_.push_back(net::UploadData::Element());
- upload_content_.back().SetToFilePathRange(filepath, offset, length);
+ upload_content_.back().SetToFilePathRange(filepath, offset, length,
+ base::Time());
}
CPError Start(int renderer_id, int render_view_id) {
@@ -186,7 +187,8 @@ class PluginRequestHandlerProxy
bridge_->AppendFileRangeToUpload(
upload_content_[i].file_path(),
upload_content_[i].file_range_offset(),
- upload_content_[i].file_range_length());
+ upload_content_[i].file_range_length(),
+ upload_content_[i].expected_file_modification_time());
break;
}
default: {
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 534cd75..1f6736f 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -98,6 +98,21 @@ bool RendererWebKitClientImpl::getFileSize(const WebString& path,
return false;
}
+bool RendererWebKitClientImpl::getFileModificationTime(
+ const WebKit::WebString& path,
+ double& result) {
+ base::Time time;
+ if (RenderThread::current()->Send(
+ new ViewHostMsg_GetFileModificationTime(
+ webkit_glue::WebStringToFilePath(path), &time))) {
+ result = time.ToDoubleT();
+ return true;
+ }
+
+ result = 0;
+ return false;
+}
+
unsigned long long RendererWebKitClientImpl::visitedLinkHash(
const char* canonical_url,
size_t length) {
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index 71154c8..f041851 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -35,6 +35,8 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebCookieJar* cookieJar();
virtual bool sandboxEnabled();
virtual bool getFileSize(const WebKit::WebString& path, long long& result);
+ virtual bool getFileModificationTime(const WebKit::WebString& path,
+ double& result);
virtual unsigned long long visitedLinkHash(
const char* canonicalURL, size_t length);
virtual bool isLinkVisited(unsigned long long linkHash);
diff --git a/chrome/renderer/translate/page_translator_unittest.cc b/chrome/renderer/translate/page_translator_unittest.cc
index 18d293a..02f1b32 100644
--- a/chrome/renderer/translate/page_translator_unittest.cc
+++ b/chrome/renderer/translate/page_translator_unittest.cc
@@ -73,8 +73,11 @@ class DummyResourceLoaderBridge : public webkit_glue::ResourceLoaderBridge {
DummyResourceLoaderBridge() { }
virtual void AppendDataToUpload(const char* data, int data_len) {}
- virtual void AppendFileRangeToUpload(const FilePath& file_path,
- uint64 offset, uint64 length) {}
+ virtual void AppendFileRangeToUpload(
+ const FilePath& file_path,
+ uint64 offset,
+ uint64 length,
+ const base::Time& expected_modification_time) {}
virtual void SetUploadIdentifier(int64 identifier) {}
virtual bool Start(Peer* peer) { return false; }
virtual void Cancel() {}