OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "net/base/file_stream.h" | 5 #include "net/base/file_stream.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 FileStream::AsyncContext::~AsyncContext() { | 72 FileStream::AsyncContext::~AsyncContext() { |
73 bool waited = false; | 73 bool waited = false; |
74 base::Time start = base::Time::Now(); | 74 base::Time start = base::Time::Now(); |
75 while (callback_) { | 75 while (callback_) { |
76 waited = true; | 76 waited = true; |
77 MessageLoopForIO::current()->WaitForIOCompletion(INFINITE, this); | 77 MessageLoopForIO::current()->WaitForIOCompletion(INFINITE, this); |
78 } | 78 } |
79 if (waited) { | 79 if (waited) { |
80 // We want to see if we block the message loop for too long. | 80 // We want to see if we block the message loop for too long. |
81 UMA_HISTOGRAM_TIMES(L"AsyncIO.FileStreamClose", base::Time::Now() - start); | 81 UMA_HISTOGRAM_TIMES("AsyncIO.FileStreamClose", base::Time::Now() - start); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 void FileStream::AsyncContext::IOCompletionIsPending( | 85 void FileStream::AsyncContext::IOCompletionIsPending( |
86 CompletionCallback* callback) { | 86 CompletionCallback* callback) { |
87 DCHECK(!callback_); | 87 DCHECK(!callback_); |
88 callback_ = callback; | 88 callback_ = callback; |
89 } | 89 } |
90 | 90 |
91 void FileStream::AsyncContext::OnIOCompleted( | 91 void FileStream::AsyncContext::OnIOCompleted( |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } else if (overlapped) { | 281 } else if (overlapped) { |
282 async_context_->IOCompletionIsPending(callback); | 282 async_context_->IOCompletionIsPending(callback); |
283 rv = ERR_IO_PENDING; | 283 rv = ERR_IO_PENDING; |
284 } else { | 284 } else { |
285 rv = static_cast<int>(bytes_written); | 285 rv = static_cast<int>(bytes_written); |
286 } | 286 } |
287 return rv; | 287 return rv; |
288 } | 288 } |
289 | 289 |
290 } // namespace net | 290 } // namespace net |
291 | |
OLD | NEW |