Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: net/base/upload_file_element_reader.cc

Issue 46303005: Fix chrome upload with content uri (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simplify the change using FILE enum instead of adding a new enum Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/upload_file_element_reader.cc
diff --git a/net/base/upload_file_element_reader.cc b/net/base/upload_file_element_reader.cc
index d1f2a12ac8cd13c6d5037032f13cdd98baf2ea03..6f7778c4a593b8e1219f9c1ef031d21d67089392 100644
--- a/net/base/upload_file_element_reader.cc
+++ b/net/base/upload_file_element_reader.cc
@@ -12,6 +12,10 @@
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#if defined(OS_ANDROID)
+#include "net/android/content_uri_utils.h"
+#endif
+
namespace net {
namespace {
@@ -45,6 +49,14 @@ int InitInternal(const base::FilePath& path,
}
}
+#if defined(OS_ANDROID)
+ int64 length = std::max(0ll, GetContentUrlLengthSync(path));
kinuko 2013/10/31 06:10:51 Can this part be factored out as a separate static
joth 2013/10/31 06:42:39 +1 Maybe even, bundling this logic into file_util
qinmin 2013/11/05 01:41:31 Done. GetFileInfo() should work for content url no
+ if (file_stream.get() && length > 0 &&
+ range_offset < static_cast<uint64>(length)) {
mmenke 2013/10/31 15:07:06 This class is being modified to handle errors diff
qinmin 2013/11/05 01:41:31 Done.
+ // Compensate for the offset.
+ length = std::min(length - range_offset, range_length);
+ }
+#else
int64 length = 0;
if (file_stream.get() &&
file_util::GetFileSize(path, &length) &&
@@ -52,6 +64,7 @@ int InitInternal(const base::FilePath& path,
// Compensate for the offset.
length = std::min(length - range_offset, range_length);
}
+#endif
*out_content_length = length;
out_file_stream->reset(file_stream.release());

Powered by Google App Engine
This is Rietveld 408576698