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

Side by Side 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: simplify the change using FILE enum instead of adding a new enum 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/file_stream_context.h" 5 #include "net/base/file_stream_context.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 if (!async_in_progress_) { 57 if (!async_in_progress_) {
58 CloseAndDelete(); 58 CloseAndDelete();
59 } else if (file_ != base::kInvalidPlatformFileValue) { 59 } else if (file_ != base::kInvalidPlatformFileValue) {
60 CancelIo(file_); 60 CancelIo(file_);
61 } 61 }
62 } 62 }
63 63
64 void FileStream::Context::OpenAsync(const base::FilePath& path, 64 void FileStream::Context::OpenAsync(const base::FilePath& path,
65 int open_flags, 65 int open_flags,
66 const CompletionCallback& callback) { 66 const CompletionCallback& callback) {
67 #if defined(OS_ANDROID)
68 if (path.IsContentUrl()) {
69 OpenContentUrlAsync(path, open_flags, callback);
70 return;
71 }
72 #endif
67 DCHECK(!async_in_progress_); 73 DCHECK(!async_in_progress_);
68 74
69 BeginOpenEvent(path); 75 BeginOpenEvent(path);
70 76
71 const bool posted = base::PostTaskAndReplyWithResult( 77 const bool posted = base::PostTaskAndReplyWithResult(
72 task_runner_.get(), 78 task_runner_.get(),
73 FROM_HERE, 79 FROM_HERE,
74 base::Bind( 80 base::Bind(
75 &Context::OpenFileImpl, base::Unretained(this), path, open_flags), 81 &Context::OpenFileImpl, base::Unretained(this), path, open_flags),
76 base::Bind(&Context::OnOpenCompleted, base::Unretained(this), callback)); 82 base::Bind(&Context::OnOpenCompleted, base::Unretained(this), callback));
77 DCHECK(posted); 83 DCHECK(posted);
78 84
79 async_in_progress_ = true; 85 async_in_progress_ = true;
80 } 86 }
81 87
82 int FileStream::Context::OpenSync(const base::FilePath& path, int open_flags) { 88 int FileStream::Context::OpenSync(const base::FilePath& path, int open_flags) {
89 #if defined(OS_ANDROID)
90 if (path.IsContentUrl())
91 return OpenContentUrlSync(path, open_flags);
92 #endif
83 DCHECK(!async_in_progress_); 93 DCHECK(!async_in_progress_);
84 94
85 BeginOpenEvent(path); 95 BeginOpenEvent(path);
86 OpenResult result = OpenFileImpl(path, open_flags); 96 OpenResult result = OpenFileImpl(path, open_flags);
87 file_ = result.file; 97 file_ = result.file;
88 if (file_ == base::kInvalidPlatformFileValue) { 98 if (file_ == base::kInvalidPlatformFileValue) {
89 ProcessOpenError(result.error_code); 99 ProcessOpenError(result.error_code);
90 } else { 100 } else {
91 // TODO(satorux): Remove this once all async clients are migrated to use 101 // TODO(satorux): Remove this once all async clients are migrated to use
92 // Open(). crbug.com/114783 102 // Open(). crbug.com/114783
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // operation is in progress. 271 // operation is in progress.
262 async_in_progress_ = false; 272 async_in_progress_ = false;
263 if (orphaned_) 273 if (orphaned_)
264 CloseAndDelete(); 274 CloseAndDelete();
265 else 275 else
266 callback.Run(result); 276 callback.Run(result);
267 } 277 }
268 278
269 } // namespace net 279 } // namespace net
270 280
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698