From 7a6db4024aa668fd49741c4c34965ab674efaac6 Mon Sep 17 00:00:00 2001 From: "jianli@chromium.org" Date: Wed, 24 Mar 2010 23:37:50 +0000 Subject: Support sending a sliced file in chromium. BUG=none TEST=The WebKit Layout test. Review URL: http://codereview.chromium.org/594036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42559 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/upload_data.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'net/base/upload_data.h') diff --git a/net/base/upload_data.h b/net/base/upload_data.h index 3aab835..869ab68 100644 --- a/net/base/upload_data.h +++ b/net/base/upload_data.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "base/ref_counted.h" +#include "base/time.h" #include "testing/gtest/include/gtest/gtest_prod.h" namespace net { @@ -35,6 +36,10 @@ class UploadData : public base::RefCounted { const FilePath& file_path() const { return file_path_; } uint64 file_range_offset() const { return file_range_offset_; } uint64 file_range_length() const { return file_range_length_; } + // If NULL time is returned, we do not do the check. + const base::Time& expected_file_modification_time() const { + return expected_file_modification_time_; + } void SetToBytes(const char* bytes, int bytes_len) { type_ = TYPE_BYTES; @@ -42,15 +47,20 @@ class UploadData : public base::RefCounted { } void SetToFilePath(const FilePath& path) { - SetToFilePathRange(path, 0, kuint64max); + SetToFilePathRange(path, 0, kuint64max, base::Time()); } + // If expected_modification_time is NULL, we do not check for the file + // change. Also note that the granularity for comparison is time_t, not + // the full precision. void SetToFilePathRange(const FilePath& path, - uint64 offset, uint64 length) { + uint64 offset, uint64 length, + const base::Time& expected_modification_time) { type_ = TYPE_FILE; file_path_ = path; file_range_offset_ = offset; file_range_length_ = length; + expected_file_modification_time_ = expected_modification_time; } // Returns the byte-length of the element. For files that do not exist, 0 @@ -69,6 +79,7 @@ class UploadData : public base::RefCounted { FilePath file_path_; uint64 file_range_offset_; uint64 file_range_length_; + base::Time expected_file_modification_time_; bool override_content_length_; uint64 content_length_; @@ -89,9 +100,11 @@ class UploadData : public base::RefCounted { } void AppendFileRange(const FilePath& file_path, - uint64 offset, uint64 length) { + uint64 offset, uint64 length, + const base::Time& expected_modification_time) { elements_.push_back(Element()); - elements_.back().SetToFilePathRange(file_path, offset, length); + elements_.back().SetToFilePathRange(file_path, offset, length, + expected_modification_time); } // Returns the total size in bytes of the data to upload. -- cgit v1.1