Index: net/base/file_stream_context.cc |
diff --git a/net/base/file_stream_context.cc b/net/base/file_stream_context.cc |
index 5acaab6eb63bd25078a7ced3493a415c82f103bd..fc2af1baac570f9506bdda9d18af9f1ee3a89633 100644 |
--- a/net/base/file_stream_context.cc |
+++ b/net/base/file_stream_context.cc |
@@ -77,6 +77,12 @@ void FileStream::Context::Orphan() { |
orphaned_ = true; |
+#if defined(OS_WIN) |
+ // Clean up weak pointers here to ensure that they are destroyed on the |
+ // same thread where they were created. |
+ weak_ptr_factory_.InvalidateWeakPtrs(); |
+#endif |
+ |
if (!async_in_progress_) { |
CloseAndDelete(); |
} else if (file_.IsValid()) { |