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

Unified Diff: net/base/file_stream_context_android.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/file_stream_context_android.cc
diff --git a/net/base/file_stream_context_android.cc b/net/base/file_stream_context_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..69884aced40d5454461ca2e4dc1c74d67d00f318
--- /dev/null
+++ b/net/base/file_stream_context_android.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
mmenke 2013/10/31 15:07:06 file_stream_context.cc is small enough that I thin
qinmin 2013/11/05 01:41:31 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/file_stream_context.h"
+
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
+#include "base/location.h"
+#include "base/platform_file.h"
+#include "base/task_runner_util.h"
+#include "net/android/content_uri_utils.h"
+#include "net/base/net_errors.h"
+
+namespace net {
+
+void FileStream::Context::OpenContentUrlAsync(
+ const base::FilePath& path,
+ int open_flags,
+ const CompletionCallback& callback) {
+ DCHECK(!async_in_progress_);
+ const bool posted = base::PostTaskAndReplyWithResult(
+ task_runner_.get(),
+ FROM_HERE,
+ base::Bind(&Context::OpenContentUrlImpl, base::Unretained(this),
joth 2013/10/31 06:42:39 the unretained is slightly scary but I see file_st
mmenke 2013/10/31 15:07:06 The FileStreamContext basically owns itself, and w
+ path, open_flags),
+ base::Bind(&Context::OnOpenCompleted, base::Unretained(this), callback));
+ DCHECK(posted);
+
+ async_in_progress_ = true;
+}
+
+int FileStream::Context::OpenContentUrlSync(
+ const base::FilePath& path, int open_flags) {
+ DCHECK(!async_in_progress_);
+
+ OpenResult result = OpenContentUrlImpl(path, open_flags);
+ file_ = result.file;
+ if (file_ == base::kInvalidPlatformFileValue) {
+ ProcessOpenError(result.error_code);
+ } else {
+ if (open_flags & base::PLATFORM_FILE_ASYNC)
+ OnAsyncFileOpened();
+ }
+ return result.error_code.result;
+}
+
+FileStream::Context::OpenResult FileStream::Context::OpenContentUrlImpl(
+ const base::FilePath& path, int open_flags) {
+ // Check that only Read flags are set.
+ DCHECK_EQ(open_flags & ~base::PLATFORM_FILE_ASYNC,
+ base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ);
+ base::PlatformFile file = OpenContentUrlForRead(path);
+ if (file == base::kInvalidPlatformFileValue)
+ return OpenResult(file, IOResult::FromOSError(GetLastErrno()));
+
+ return OpenResult(file, IOResult(OK, 0));
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698