OLD | NEW |
---|---|
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_proxy.h" | 8 #include "base/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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 } | 144 } |
145 | 145 |
146 void FileStream::Context::BeginOpenEvent(const FilePath& path) { | 146 void FileStream::Context::BeginOpenEvent(const FilePath& path) { |
147 std::string file_name = path.AsUTF8Unsafe(); | 147 std::string file_name = path.AsUTF8Unsafe(); |
148 bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_OPEN, | 148 bound_net_log_.BeginEvent(NetLog::TYPE_FILE_STREAM_OPEN, |
149 NetLog::StringCallback("file_name", &file_name)); | 149 NetLog::StringCallback("file_name", &file_name)); |
150 } | 150 } |
151 | 151 |
152 FileStream::Context::OpenResult FileStream::Context::OpenFileImpl( | 152 FileStream::Context::OpenResult FileStream::Context::OpenFileImpl( |
153 const FilePath& path, int open_flags) { | 153 const FilePath& path, int open_flags) { |
154 // FileStream::Context actually closes the file asynchronously, independently | |
155 // from FileStream's destructor. It can cause problems for users wanting to | |
156 // delete the file right after FileStream deletion. Thus we are always | |
157 // adding SHARE_DELETE flag to accommodate such use case. | |
wtc
2012/12/12 20:05:17
I suggest clarifying this comment as follows.
1.
| |
158 open_flags |= base::PLATFORM_FILE_SHARE_DELETE; | |
154 OpenResult result; | 159 OpenResult result; |
155 result.error_code = OK; | 160 result.error_code = OK; |
156 result.file = base::CreatePlatformFile(path, open_flags, NULL, NULL); | 161 result.file = base::CreatePlatformFile(path, open_flags, NULL, NULL); |
157 if (result.file == base::kInvalidPlatformFileValue) | 162 if (result.file == base::kInvalidPlatformFileValue) |
158 result.error_code = GetLastErrno(); | 163 result.error_code = GetLastErrno(); |
159 | 164 |
160 return result; | 165 return result; |
161 } | 166 } |
162 | 167 |
163 int FileStream::Context::ProcessOpenError(int error_code) { | 168 int FileStream::Context::ProcessOpenError(int error_code) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 // operation is in progress. | 227 // operation is in progress. |
223 async_in_progress_ = false; | 228 async_in_progress_ = false; |
224 if (orphaned_) | 229 if (orphaned_) |
225 CloseAndDelete(); | 230 CloseAndDelete(); |
226 else | 231 else |
227 callback.Run(result); | 232 callback.Run(result); |
228 } | 233 } |
229 | 234 |
230 } // namespace net | 235 } // namespace net |
231 | 236 |
OLD | NEW |