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/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_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return *this; | 70 return *this; |
71 } | 71 } |
72 | 72 |
73 // --------------------------------------------------------------------- | 73 // --------------------------------------------------------------------- |
74 | 74 |
75 void FileStream::Context::Orphan() { | 75 void FileStream::Context::Orphan() { |
76 DCHECK(!orphaned_); | 76 DCHECK(!orphaned_); |
77 | 77 |
78 orphaned_ = true; | 78 orphaned_ = true; |
79 | 79 |
80 #if defined(OS_WIN) | |
81 // Clean up weak pointers here to ensure that they are destroyed on the | |
82 // same thread where they were created. | |
83 weak_ptr_factory_.InvalidateWeakPtrs(); | |
84 #endif | |
85 | |
86 if (!async_in_progress_) { | 80 if (!async_in_progress_) { |
87 CloseAndDelete(); | 81 CloseAndDelete(); |
88 } else if (file_.IsValid()) { | 82 } else if (file_.IsValid()) { |
89 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
90 CancelIo(file_.GetPlatformFile()); | 84 CancelIo(file_.GetPlatformFile()); |
91 #endif | 85 #endif |
92 } | 86 } |
93 } | 87 } |
94 | 88 |
95 void FileStream::Context::Open(const base::FilePath& path, | 89 void FileStream::Context::Open(const base::FilePath& path, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 208 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
215 "423948 FileStream::Context::OnOpenCompleted")); | 209 "423948 FileStream::Context::OnOpenCompleted")); |
216 | 210 |
217 OnFileOpened(); | 211 OnFileOpened(); |
218 } | 212 } |
219 | 213 |
220 OnAsyncCompleted(IntToInt64(callback), open_result.error_code); | 214 OnAsyncCompleted(IntToInt64(callback), open_result.error_code); |
221 } | 215 } |
222 | 216 |
223 void FileStream::Context::CloseAndDelete() { | 217 void FileStream::Context::CloseAndDelete() { |
224 DCHECK(!async_in_progress_); | 218 // TODO(ananta) |
| 219 // Replace this CHECK with a DCHECK once we figure out the root cause of |
| 220 // http://crbug.com/455066 |
| 221 CHECK(!async_in_progress_); |
225 | 222 |
226 if (file_.IsValid()) { | 223 if (file_.IsValid()) { |
227 bool posted = task_runner_.get()->PostTask( | 224 bool posted = task_runner_.get()->PostTask( |
228 FROM_HERE, | 225 FROM_HERE, |
229 base::Bind(base::IgnoreResult(&Context::CloseFileImpl), | 226 base::Bind(base::IgnoreResult(&Context::CloseFileImpl), |
230 base::Owned(this))); | 227 base::Owned(this))); |
231 DCHECK(posted); | 228 DCHECK(posted); |
232 } else { | 229 } else { |
233 delete this; | 230 delete this; |
234 } | 231 } |
(...skipping 11 matching lines...) Expand all Loading... |
246 // should be reset before Close() because it shouldn't run if any async | 243 // should be reset before Close() because it shouldn't run if any async |
247 // operation is in progress. | 244 // operation is in progress. |
248 async_in_progress_ = false; | 245 async_in_progress_ = false; |
249 if (orphaned_) | 246 if (orphaned_) |
250 CloseAndDelete(); | 247 CloseAndDelete(); |
251 else | 248 else |
252 callback.Run(result.result); | 249 callback.Run(result.result); |
253 } | 250 } |
254 | 251 |
255 } // namespace net | 252 } // namespace net |
OLD | NEW |