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 "remoting/protocol/buffered_socket_writer.h" | 5 #include "remoting/protocol/buffered_socket_writer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 DCHECK(data.get()); | 48 DCHECK(data.get()); |
49 | 49 |
50 // Don't write after Close(). | 50 // Don't write after Close(). |
51 if (closed_) | 51 if (closed_) |
52 return false; | 52 return false; |
53 | 53 |
54 queue_.push_back(new PendingPacket(data, done_task)); | 54 queue_.push_back(new PendingPacket(data, done_task)); |
55 buffer_size_ += data->size(); | 55 buffer_size_ += data->size(); |
56 | 56 |
57 DoWrite(); | 57 DoWrite(); |
58 return true; | 58 |
| 59 // DoWrite() may trigger OnWriteError() to be called. |
| 60 return !closed_; |
59 } | 61 } |
60 | 62 |
61 void BufferedSocketWriterBase::DoWrite() { | 63 void BufferedSocketWriterBase::DoWrite() { |
62 DCHECK(CalledOnValidThread()); | 64 DCHECK(CalledOnValidThread()); |
63 DCHECK(socket_); | 65 DCHECK(socket_); |
64 | 66 |
65 // Don't try to write if there is another write pending. | 67 // Don't try to write if there is another write pending. |
66 if (write_pending_) | 68 if (write_pending_) |
67 return; | 69 return; |
68 | 70 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 227 |
226 void BufferedDatagramWriter::OnError(int result) { | 228 void BufferedDatagramWriter::OnError(int result) { |
227 // Nothing to do here. | 229 // Nothing to do here. |
228 } | 230 } |
229 | 231 |
230 BufferedDatagramWriter::~BufferedDatagramWriter() { | 232 BufferedDatagramWriter::~BufferedDatagramWriter() { |
231 } | 233 } |
232 | 234 |
233 } // namespace protocol | 235 } // namespace protocol |
234 } // namespace remoting | 236 } // namespace remoting |
OLD | NEW |