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 |
80 if (!async_in_progress_) { | 86 if (!async_in_progress_) { |
81 CloseAndDelete(); | 87 CloseAndDelete(); |
82 } else if (file_.IsValid()) { | 88 } else if (file_.IsValid()) { |
83 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
84 CancelIo(file_.GetPlatformFile()); | 90 CancelIo(file_.GetPlatformFile()); |
85 #endif | 91 #endif |
86 } | 92 } |
87 } | 93 } |
88 | 94 |
89 void FileStream::Context::Open(const base::FilePath& path, | 95 void FileStream::Context::Open(const base::FilePath& path, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // should be reset before Close() because it shouldn't run if any async | 246 // should be reset before Close() because it shouldn't run if any async |
241 // operation is in progress. | 247 // operation is in progress. |
242 async_in_progress_ = false; | 248 async_in_progress_ = false; |
243 if (orphaned_) | 249 if (orphaned_) |
244 CloseAndDelete(); | 250 CloseAndDelete(); |
245 else | 251 else |
246 callback.Run(result.result); | 252 callback.Run(result.result); |
247 } | 253 } |
248 | 254 |
249 } // namespace net | 255 } // namespace net |
OLD | NEW |