diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 23:37:50 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 23:37:50 +0000 |
commit | 7a6db4024aa668fd49741c4c34965ab674efaac6 (patch) | |
tree | 291de61ee2f86da940a5c9c0a67a79d394478a8e /webkit/glue | |
parent | e8b3ddfde11a59bc910697090906dd36f0426401 (diff) | |
download | chromium_src-7a6db4024aa668fd49741c4c34965ab674efaac6.zip chromium_src-7a6db4024aa668fd49741c4c34965ab674efaac6.tar.gz chromium_src-7a6db4024aa668fd49741c4c34965ab674efaac6.tar.bz2 |
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
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/glue_serialize.cc | 18 | ||||
-rw-r--r-- | webkit/glue/glue_serialize_unittest.cc | 1 | ||||
-rw-r--r-- | webkit/glue/mock_resource_loader_bridge.h | 8 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.h | 9 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.cc | 2 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.cc | 11 |
7 files changed, 41 insertions, 11 deletions
diff --git a/webkit/glue/glue_serialize.cc b/webkit/glue/glue_serialize.cc index 802f57d..4b4efd3 100644 --- a/webkit/glue/glue_serialize.cc +++ b/webkit/glue/glue_serialize.cc @@ -19,6 +19,7 @@ #include "webkit/glue/webkit_glue.h" using WebKit::WebData; +using WebKit::WebFileInfo; using WebKit::WebHistoryItem; using WebKit::WebHTTPBody; using WebKit::WebPoint; @@ -53,12 +54,13 @@ struct SerializeObject { // 5: Adds support for empty FormData // 6: Adds support for documentSequenceNumbers // 7: Adds support for stateObject +// 8: Adds support for file range and modification time // Should be const, but unit tests may modify it. // // NOTE: If the version is -1, then the pickle contains only a URL string. // See CreateHistoryStateForURL. // -int kVersion = 7; +int kVersion = 8; // A bunch of convenience functions to read/write to SerializeObjects. // The serializers assume the input data is in the correct format and so does @@ -230,6 +232,9 @@ static void WriteFormData(const WebHTTPBody& http_body, SerializeObject* obj) { obj); } else { WriteString(element.filePath, obj); + WriteInteger64(element.fileStart, obj); + WriteInteger64(element.fileLength, obj); + WriteReal(element.fileInfo.modificationTime, obj); } } WriteInteger64(http_body.identifier(), obj); @@ -257,7 +262,16 @@ static WebHTTPBody ReadFormData(const SerializeObject* obj) { if (length >= 0) http_body.appendData(WebData(static_cast<const char*>(data), length)); } else { - http_body.appendFile(ReadString(obj)); + WebString file_path = ReadString(obj); + long long file_start = 0; + long long file_length = -1; + WebFileInfo file_info; + if (obj->version >= 8) { + file_start = ReadInteger64(obj); + file_length = ReadInteger64(obj); + file_info.modificationTime = ReadReal(obj); + } + http_body.appendFileRange(file_path, file_start, file_length, file_info); } } if (obj->version >= 4) diff --git a/webkit/glue/glue_serialize_unittest.cc b/webkit/glue/glue_serialize_unittest.cc index e3d91bd..34ce09f 100644 --- a/webkit/glue/glue_serialize_unittest.cc +++ b/webkit/glue/glue_serialize_unittest.cc @@ -13,6 +13,7 @@ #include "webkit/glue/glue_serialize.h" using WebKit::WebData; +using WebKit::WebFileInfo; using WebKit::WebHistoryItem; using WebKit::WebHTTPBody; using WebKit::WebPoint; diff --git a/webkit/glue/mock_resource_loader_bridge.h b/webkit/glue/mock_resource_loader_bridge.h index a3c40ba..7176e04 100644 --- a/webkit/glue/mock_resource_loader_bridge.h +++ b/webkit/glue/mock_resource_loader_bridge.h @@ -21,9 +21,11 @@ class MockResourceLoaderBridge : public webkit_glue::ResourceLoaderBridge { } MOCK_METHOD2(AppendDataToUpload, void(const char* data, int data_len)); - MOCK_METHOD3(AppendFileRangeToUpload, void(const FilePath& file_path, - uint64 offset, - uint64 length)); + MOCK_METHOD4(AppendFileRangeToUpload, + void(const FilePath& file_path, + uint64 offset, + uint64 length, + const base::Time& expected_modification_time)); MOCK_METHOD1(SetUploadIdentifier, void(int64 identifier)); MOCK_METHOD1(Start, bool(ResourceLoaderBridge::Peer* peer)); MOCK_METHOD0(Cancel, void()); diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index a1ede6c..26253f8 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -208,13 +208,16 @@ class ResourceLoaderBridge { // Call this method before calling Start() to append the contents of a file // to the request body. May only be used with HTTP(S) POST requests. void AppendFileToUpload(const FilePath& file_path) { - AppendFileRangeToUpload(file_path, 0, kuint64max); + AppendFileRangeToUpload(file_path, 0, kuint64max, base::Time()); } // Call this method before calling Start() to append the contents of a file // to the request body. May only be used with HTTP(S) POST requests. - virtual void AppendFileRangeToUpload(const FilePath& file_path, - uint64 offset, uint64 length) = 0; + virtual void AppendFileRangeToUpload( + const FilePath& file_path, + uint64 offset, + uint64 length, + const base::Time& expected_modification_time) = 0; // Call this method before calling Start() to assign an upload identifier to // this request. This is used to enable caching of POST responses. A value diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc index 4695c24..a8fcac3 100644 --- a/webkit/glue/webkitclient_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -454,7 +454,7 @@ bool WebKitClientImpl::getFileSize(const WebKit::WebString& path, } bool WebKitClientImpl::getFileModificationTime(const WebKit::WebString& path, - time_t& result) { + double& result) { NOTREACHED(); return false; } diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h index df1f9c7..3017e94e 100644 --- a/webkit/glue/webkitclient_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -30,7 +30,8 @@ class WebKitClientImpl : public WebKit::WebKitClient { virtual bool deleteEmptyDirectory(const WebKit::WebString& path); virtual bool getFileSize(const WebKit::WebString& path, long long& result); virtual bool getFileModificationTime( - const WebKit::WebString& path, time_t& result); + const WebKit::WebString& path, + double& result); virtual WebKit::WebString directoryName(const WebKit::WebString& path); virtual WebKit::WebString pathByAppendingComponent( const WebKit::WebString& path, const WebKit::WebString& component); diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 421cb8f..d1d17a4 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -375,7 +375,16 @@ void WebURLLoaderImpl::Context::Start( } break; case WebHTTPBody::Element::TypeFile: - bridge_->AppendFileToUpload(WebStringToFilePath(element.filePath)); + if (element.fileLength == -1) { + bridge_->AppendFileToUpload( + WebStringToFilePath(element.filePath)); + } else { + bridge_->AppendFileRangeToUpload( + WebStringToFilePath(element.filePath), + static_cast<uint64>(element.fileStart), + static_cast<uint64>(element.fileLength), + base::Time::FromDoubleT(element.fileInfo.modificationTime)); + } break; default: NOTREACHED(); |