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

Side by Side Diff: net/base/file_stream_context.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/android/OWNERS ('k') | net/base/filename_util_internal.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/profiler/scoped_profile.h" 10 #include "base/profiler/scoped_tracker.h"
11 #include "base/task_runner.h" 11 #include "base/task_runner.h"
12 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 16
17 #if defined(OS_ANDROID) 17 #if defined(OS_ANDROID)
18 #include "base/android/content_uri_utils.h" 18 #include "base/android/content_uri_utils.h"
19 #endif 19 #endif
20 20
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 base::Bind(&Context::OnAsyncCompleted, 143 base::Bind(&Context::OnAsyncCompleted,
144 base::Unretained(this), 144 base::Unretained(this),
145 IntToInt64(callback))); 145 IntToInt64(callback)));
146 DCHECK(posted); 146 DCHECK(posted);
147 147
148 async_in_progress_ = true; 148 async_in_progress_ = true;
149 } 149 }
150 150
151 FileStream::Context::OpenResult FileStream::Context::OpenFileImpl( 151 FileStream::Context::OpenResult FileStream::Context::OpenFileImpl(
152 const base::FilePath& path, int open_flags) { 152 const base::FilePath& path, int open_flags) {
153 // TODO(vadimt): Remove ScopedProfile below once crbug.com/423948 is fixed. 153 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
154 tracked_objects::ScopedProfile tracking_profile( 154 tracked_objects::ScopedTracker tracking_profile(
155 FROM_HERE_WITH_EXPLICIT_FUNCTION( 155 FROM_HERE_WITH_EXPLICIT_FUNCTION(
156 "423948 FileStream::Context::OpenFileImpl")); 156 "423948 FileStream::Context::OpenFileImpl"));
157 157
158 #if defined(OS_POSIX) 158 #if defined(OS_POSIX)
159 // Always use blocking IO. 159 // Always use blocking IO.
160 open_flags &= ~base::File::FLAG_ASYNC; 160 open_flags &= ~base::File::FLAG_ASYNC;
161 #endif 161 #endif
162 base::File file; 162 base::File file;
163 #if defined(OS_ANDROID) 163 #if defined(OS_ANDROID)
164 if (path.IsContentUri()) { 164 if (path.IsContentUri()) {
(...skipping 30 matching lines...) Expand all
195 if (file_.Flush()) 195 if (file_.Flush())
196 return IOResult(OK, 0); 196 return IOResult(OK, 0);
197 197
198 return IOResult::FromOSError(logging::GetLastSystemErrorCode()); 198 return IOResult::FromOSError(logging::GetLastSystemErrorCode());
199 } 199 }
200 200
201 void FileStream::Context::OnOpenCompleted(const CompletionCallback& callback, 201 void FileStream::Context::OnOpenCompleted(const CompletionCallback& callback,
202 OpenResult open_result) { 202 OpenResult open_result) {
203 file_ = open_result.file.Pass(); 203 file_ = open_result.file.Pass();
204 if (file_.IsValid() && !orphaned_) { 204 if (file_.IsValid() && !orphaned_) {
205 // TODO(vadimt): Remove ScopedProfile below once crbug.com/423948 is fixed. 205 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
206 tracked_objects::ScopedProfile tracking_profile( 206 tracked_objects::ScopedTracker tracking_profile(
207 FROM_HERE_WITH_EXPLICIT_FUNCTION( 207 FROM_HERE_WITH_EXPLICIT_FUNCTION(
208 "423948 FileStream::Context::OnOpenCompleted")); 208 "423948 FileStream::Context::OnOpenCompleted"));
209 209
210 OnFileOpened(); 210 OnFileOpened();
211 } 211 }
212 212
213 OnAsyncCompleted(IntToInt64(callback), open_result.error_code); 213 OnAsyncCompleted(IntToInt64(callback), open_result.error_code);
214 } 214 }
215 215
216 void FileStream::Context::CloseAndDelete() { 216 void FileStream::Context::CloseAndDelete() {
(...skipping 22 matching lines...) Expand all
239 // should be reset before Close() because it shouldn't run if any async 239 // should be reset before Close() because it shouldn't run if any async
240 // operation is in progress. 240 // operation is in progress.
241 async_in_progress_ = false; 241 async_in_progress_ = false;
242 if (orphaned_) 242 if (orphaned_)
243 CloseAndDelete(); 243 CloseAndDelete();
244 else 244 else
245 callback.Run(result.result); 245 callback.Run(result.result);
246 } 246 }
247 247
248 } // namespace net 248 } // namespace net
OLDNEW
« no previous file with comments | « net/android/OWNERS ('k') | net/base/filename_util_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698