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

Unified Diff: net/base/file_stream_context.cc

Issue 46303005: Fix chrome upload with content uri (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing mmenke's comments Created 7 years, 1 month 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/file_stream_context.cc
diff --git a/net/base/file_stream_context.cc b/net/base/file_stream_context.cc
index 2e774752045d9c0d0e6a8c82dc3dfc7a6bb9c366..cfa8abfb59bfeeb5cb3b3fd1ef153b03c94e3713 100644
--- a/net/base/file_stream_context.cc
+++ b/net/base/file_stream_context.cc
@@ -11,6 +11,10 @@
#include "net/base/file_stream_net_log_parameters.h"
#include "net/base/net_errors.h"
+#if defined(OS_ANDROID)
+#include "base/android/content_uri_utils.h"
+#endif
+
namespace {
void CallInt64ToInt(const net::CompletionCallback& callback, int64 result) {
@@ -193,13 +197,24 @@ void FileStream::Context::BeginOpenEvent(const base::FilePath& path) {
FileStream::Context::OpenResult FileStream::Context::OpenFileImpl(
const base::FilePath& path, int open_flags) {
+ base::PlatformFile file;
+#if defined(OS_ANDROID)
+ if (path.IsContentUrl()) {
+ // Check that only Read flags are set.
+ DCHECK_EQ(open_flags & ~base::PLATFORM_FILE_ASYNC,
+ base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ);
+ file = base::OpenContentUrlForRead(path);
+ } else {
+#endif // defined(OS_ANDROID)
// FileStream::Context actually closes the file asynchronously, independently
// from FileStream's destructor. It can cause problems for users wanting to
// delete the file right after FileStream deletion. Thus we are always
// adding SHARE_DELETE flag to accommodate such use case.
open_flags |= base::PLATFORM_FILE_SHARE_DELETE;
- base::PlatformFile file =
- base::CreatePlatformFile(path, open_flags, NULL, NULL);
+ file = base::CreatePlatformFile(path, open_flags, NULL, NULL);
mmenke 2013/11/05 15:36:04 nit: Think this is easier to read if this block i
qinmin 2013/11/07 01:13:35 Done.
+#if defined(OS_ANDROID)
+ }
+#endif // defined(OS_ANDROID)
joth 2013/11/06 01:49:17 just saw in another review [1], you can avoid the
qinmin 2013/11/07 01:13:35 Done.
if (file == base::kInvalidPlatformFileValue)
return OpenResult(file, IOResult::FromOSError(GetLastErrno()));

Powered by Google App Engine
This is Rietveld 408576698