summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-27 21:22:01 +0000
committerdumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-27 21:22:01 +0000
commited7ae173fbca0de5cb95c990fed727ea15172cd4 (patch)
treee94ae0632eec0d649dad8fa1953cf0932c35cbda
parent6783d72a34e5d25655d5c9d054f2700f3d2488ff (diff)
downloadchromium_src-ed7ae173fbca0de5cb95c990fed727ea15172cd4.zip
chromium_src-ed7ae173fbca0de5cb95c990fed727ea15172cd4.tar.gz
chromium_src-ed7ae173fbca0de5cb95c990fed727ea15172cd4.tar.bz2
Adding a TouchFile() operation.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3417018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60710 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.cc12
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.h8
-rw-r--r--chrome/common/file_system/file_system_dispatcher.cc11
-rw-r--r--chrome/common/file_system/file_system_dispatcher.h4
-rw-r--r--chrome/common/render_messages_internal.h7
-rw-r--r--webkit/fileapi/file_system_operation.cc22
-rw-r--r--webkit/fileapi/file_system_operation.h10
7 files changed, 73 insertions, 1 deletions
diff --git a/chrome/browser/file_system/file_system_dispatcher_host.cc b/chrome/browser/file_system/file_system_dispatcher_host.cc
index 324612d..18daec8 100644
--- a/chrome/browser/file_system/file_system_dispatcher_host.cc
+++ b/chrome/browser/file_system/file_system_dispatcher_host.cc
@@ -110,6 +110,7 @@ bool FileSystemDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_ReadDirectory, OnReadDirectory)
IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Write, OnWrite)
IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_Truncate, OnTruncate)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_TouchFile, OnTouchFile)
IPC_MESSAGE_HANDLER(ViewHostMsg_FileSystem_CancelWrite, OnCancel)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -220,6 +221,17 @@ void FileSystemDispatcherHost::OnTruncate(
GetNewOperation(request_id)->Truncate(path, length);
}
+void FileSystemDispatcherHost::OnTouchFile(
+ int request_id,
+ const FilePath& path,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time) {
+ if (!CheckValidFileSystemPath(path, request_id))
+ return;
+ GetNewOperation(request_id)->TouchFile(
+ path, last_access_time, last_modified_time);
+}
+
void FileSystemDispatcherHost::OnCancel(
int request_id,
int request_id_to_cancel) {
diff --git a/chrome/browser/file_system/file_system_dispatcher_host.h b/chrome/browser/file_system/file_system_dispatcher_host.h
index 20bb77c..22a560a 100644
--- a/chrome/browser/file_system/file_system_dispatcher_host.h
+++ b/chrome/browser/file_system/file_system_dispatcher_host.h
@@ -17,6 +17,10 @@
#include "webkit/fileapi/file_system_operation.h"
#include "webkit/fileapi/file_system_types.h"
+namespace base {
+class Time;
+}
+
class ChromeFileSystemOperation;
class FileSystemHostContext;
class GURL;
@@ -60,6 +64,10 @@ class FileSystemDispatcherHost
const GURL& blob_url,
int64 offset);
void OnTruncate(int request_id, const FilePath& path, int64 length);
+ void OnTouchFile(int request_id,
+ const FilePath& path,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time);
void OnCancel(int request_id, int request_to_cancel);
void Send(IPC::Message* message);
void RemoveCompletedOperation(int request_id);
diff --git a/chrome/common/file_system/file_system_dispatcher.cc b/chrome/common/file_system/file_system_dispatcher.cc
index 6f5d2a3..0e46c97 100644
--- a/chrome/common/file_system/file_system_dispatcher.cc
+++ b/chrome/common/file_system/file_system_dispatcher.cc
@@ -108,6 +108,17 @@ bool FileSystemDispatcher::ReadDirectory(
new ViewHostMsg_FileSystem_ReadDirectory(request_id, path));
}
+bool FileSystemDispatcher::TouchFile(
+ const FilePath& path,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time,
+ fileapi::FileSystemCallbackDispatcher* dispatcher) {
+ int request_id = dispatchers_.Add(dispatcher);
+ return ChildThread::current()->Send(
+ new ViewHostMsg_FileSystem_TouchFile(
+ request_id, path, last_access_time, last_modified_time));
+}
+
void FileSystemDispatcher::OnOpenFileSystemRequestComplete(
int request_id, bool accepted, const std::string& name,
const FilePath& root_path) {
diff --git a/chrome/common/file_system/file_system_dispatcher.h b/chrome/common/file_system/file_system_dispatcher.h
index 58b3cc72..ec20e6d 100644
--- a/chrome/common/file_system/file_system_dispatcher.h
+++ b/chrome/common/file_system/file_system_dispatcher.h
@@ -56,6 +56,10 @@ class FileSystemDispatcher {
fileapi::FileSystemCallbackDispatcher* dispatcher);
bool ReadDirectory(const FilePath& path,
fileapi::FileSystemCallbackDispatcher* dispatcher);
+ bool TouchFile(const FilePath& file_path,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time,
+ fileapi::FileSystemCallbackDispatcher* dispatcher);
private:
// Message handler for OpenFileSystem.
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index bc5f1f3..78ecabd 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -2857,6 +2857,13 @@ IPC_BEGIN_MESSAGES(ViewHost)
FilePath /* file path */,
int64 /* length */)
+ // Pepper's Touch() message.
+ IPC_MESSAGE_CONTROL4(ViewHostMsg_FileSystem_TouchFile,
+ int /* request_id */,
+ FilePath /* path */,
+ base::Time /* last_access_time */,
+ base::Time /* last_modified_time */)
+
// WebFileWriter::cancel() message.
IPC_MESSAGE_CONTROL2(ViewHostMsg_FileSystem_CancelWrite,
int /* request id */,
diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc
index ffe5e5f..140ade4 100644
--- a/webkit/fileapi/file_system_operation.cc
+++ b/webkit/fileapi/file_system_operation.cc
@@ -4,6 +4,7 @@
#include "webkit/fileapi/file_system_operation.h"
+#include "base/time.h"
#include "googleurl/src/gurl.h"
#include "webkit/fileapi/file_system_callback_dispatcher.h"
@@ -126,7 +127,6 @@ void FileSystemOperation::Remove(const FilePath& path) {
&FileSystemOperation::DidFinishFileOperation));
}
-
void FileSystemOperation::Write(
const FilePath&,
const GURL&,
@@ -152,6 +152,19 @@ void FileSystemOperation::Truncate(const FilePath& path, int64 length) {
NOTREACHED();
}
+void FileSystemOperation::TouchFile(const FilePath& path,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time) {
+#ifndef NDEBUG
+ DCHECK(!operation_pending_);
+ operation_pending_ = true;
+#endif
+
+ base::FileUtilProxy::Touch(
+ proxy_, path, last_access_time, last_modified_time,
+ callback_factory_.NewCallback(&FileSystemOperation::DidTouchFile));
+}
+
void FileSystemOperation::Cancel() {
#ifndef NDEBUG
DCHECK(operation_pending_);
@@ -242,4 +255,11 @@ void FileSystemOperation::DidWrite(
dispatcher_->DidFail(rv);
}
+void FileSystemOperation::DidTouchFile(base::PlatformFileError rv) {
+ if (rv == base::PLATFORM_FILE_OK)
+ dispatcher_->DidSucceed();
+ else
+ dispatcher_->DidFail(rv);
+}
+
} // namespace fileapi
diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h
index e1058a3..1107303 100644
--- a/webkit/fileapi/file_system_operation.h
+++ b/webkit/fileapi/file_system_operation.h
@@ -15,6 +15,10 @@
#include "base/scoped_callback_factory.h"
#include "base/scoped_ptr.h"
+namespace base {
+class Time;
+}
+
class GURL;
namespace fileapi {
@@ -62,6 +66,10 @@ class FileSystemOperation {
void Truncate(const FilePath& path, int64 length);
+ void TouchFile(const FilePath& path,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time);
+
// Used to attempt to cancel the current operation. This currently does
// nothing for any operation other than Write().
void Cancel();
@@ -100,6 +108,8 @@ class FileSystemOperation {
int64 bytes,
bool complete);
+ void DidTouchFile(base::PlatformFileError rv);
+
scoped_ptr<FileSystemCallbackDispatcher> dispatcher_;
base::ScopedCallbackFactory<FileSystemOperation> callback_factory_;