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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // should be reset before Close() because it shouldn't run if any async | 240 // should be reset before Close() because it shouldn't run if any async |
247 // operation is in progress. | 241 // operation is in progress. |
248 async_in_progress_ = false; | 242 async_in_progress_ = false; |
249 if (orphaned_) | 243 if (orphaned_) |
250 CloseAndDelete(); | 244 CloseAndDelete(); |
251 else | 245 else |
252 callback.Run(result.result); | 246 callback.Run(result.result); |
253 } | 247 } |
254 | 248 |
255 } // namespace net | 249 } // namespace net |
OLD | NEW |