Index: net/base/upload_data.h |
diff --git a/net/base/upload_data.h b/net/base/upload_data.h |
index 31c1958a6966c9e321f554754819b54f0c98726e..43d209b31dd141bd60697bfec3973761b19d84fb 100644 |
--- a/net/base/upload_data.h |
+++ b/net/base/upload_data.h |
@@ -9,6 +9,7 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/callback_forward.h" |
#include "base/file_path.h" |
#include "base/gtest_prod_util.h" |
#include "base/memory/ref_counted.h" |
@@ -107,7 +108,6 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> { |
// Returns the byte-length of the element. For files that do not exist, 0 |
// is returned. This is done for consistency with Mozilla. |
- // Once called, this function will always return the same value. |
uint64 GetContentLength(); |
// Returns a FileStream opened for reading for this element, positioned at |
@@ -163,8 +163,26 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> { |
void set_is_chunked(bool set) { is_chunked_ = set; } |
bool is_chunked() const { return is_chunked_; } |
+ // Gets the total size in bytes of the data to upload. Computing the |
+ // content length can result in performing file IO hence the operation is |
+ // done asynchronously. Runs the callback with the content length once the |
+ // computation is done. |
+ typedef base::Callback<void(uint64 content_length)> ContentLengthCallback; |
+ void GetContentLength(const ContentLengthCallback& callback); |
+ |
+ // Returns the total size in bytes of the data to upload, for testing. |
+ // This version may perform file IO on the current thread. This function |
+ // will fail if called on a thread where file IO is prohibited. Usually |
+ // used for testing, but Chrome Frame also uses this version. |
+ uint64 GetContentLengthSync(); |
+ |
// Returns the total size in bytes of the data to upload. |
- uint64 GetContentLength(); |
+ // This version may perform file IO on the current thread, but |
+ // ThreadRestrictions::AllowIO is placed so this function won't crash even |
+ // if it's called on a thread where file IO is prohibited. |
+ // |
+ // TODO(satorux): Remove this once clients are gone. |
+ uint64 GetContentLengthSyncHack(); |
// Returns true if the upload data is entirely in memory (i.e. the |
// upload data is not chunked, and all elemnts are of TYPE_BYTES). |
@@ -187,6 +205,9 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> { |
int64 identifier() const { return identifier_; } |
private: |
+ // Helper function for GetContentLength(). |
+ void DoGetContentLength(uint64* content_length); |
+ |
friend class base::RefCounted<UploadData>; |
~UploadData(); |