| 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.h" | 5 #include "net/base/file_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // (i.e. TYPE_FILE_STREAM_CLOSE event is recorded). | 37 // (i.e. TYPE_FILE_STREAM_CLOSE event is recorded). |
| 38 class NetLogForNotifyingFileClosure : public NetLog { | 38 class NetLogForNotifyingFileClosure : public NetLog { |
| 39 public: | 39 public: |
| 40 NetLogForNotifyingFileClosure() | 40 NetLogForNotifyingFileClosure() |
| 41 : last_id_(0), | 41 : last_id_(0), |
| 42 on_closure_(false /* manual_reset */, false /* initially_signaled */) { | 42 on_closure_(false /* manual_reset */, false /* initially_signaled */) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Wait until a file closure event is recorded. | 45 // Wait until a file closure event is recorded. |
| 46 bool WaitForClosure() { | 46 bool WaitForClosure() { |
| 47 const base::TimeDelta timeout( | 47 const base::TimeDelta timeout(TestTimeouts::action_max_timeout()); |
| 48 base::TimeDelta::FromMilliseconds( | |
| 49 TestTimeouts::action_max_timeout_ms())); | |
| 50 return on_closure_.TimedWait(timeout); | 48 return on_closure_.TimedWait(timeout); |
| 51 } | 49 } |
| 52 | 50 |
| 53 // NetLog overrides: | 51 // NetLog overrides: |
| 54 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE { | 52 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE { |
| 55 if (entry.type() == TYPE_FILE_STREAM_CLOSE) | 53 if (entry.type() == TYPE_FILE_STREAM_CLOSE) |
| 56 on_closure_.Signal(); | 54 on_closure_.Signal(); |
| 57 } | 55 } |
| 58 | 56 |
| 59 virtual uint32 NextID() OVERRIDE { return ++last_id_; } | 57 virtual uint32 NextID() OVERRIDE { return ++last_id_; } |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 // Delete the stream without waiting for the close operation to be | 1253 // Delete the stream without waiting for the close operation to be |
| 1256 // complete. Should be safe. | 1254 // complete. Should be safe. |
| 1257 stream.reset(); | 1255 stream.reset(); |
| 1258 // close_callback won't be called. | 1256 // close_callback won't be called. |
| 1259 EXPECT_FALSE(close_callback.have_result()); | 1257 EXPECT_FALSE(close_callback.have_result()); |
| 1260 } | 1258 } |
| 1261 | 1259 |
| 1262 } // namespace | 1260 } // namespace |
| 1263 | 1261 |
| 1264 } // namespace net | 1262 } // namespace net |
| OLD | NEW |