| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/net/blimp_message_output_buffer.h" | 5 #include "blimp/net/blimp_message_output_buffer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 void BlimpMessageOutputBuffer::WriteNextMessageIfReady() { | 128 void BlimpMessageOutputBuffer::WriteNextMessageIfReady() { |
| 129 DVLOG(3) << "WriteNextMessageIfReady"; | 129 DVLOG(3) << "WriteNextMessageIfReady"; |
| 130 if (write_buffer_.empty()) { | 130 if (write_buffer_.empty()) { |
| 131 DVLOG(3) << "Nothing to write."; | 131 DVLOG(3) << "Nothing to write."; |
| 132 return; | 132 return; |
| 133 } | 133 } |
| 134 | 134 |
| 135 std::unique_ptr<BlimpMessage> message_to_write( | 135 std::unique_ptr<BlimpMessage> message_to_write( |
| 136 new BlimpMessage(*write_buffer_.front()->message)); | 136 new BlimpMessage(*write_buffer_.front()->message)); |
| 137 DVLOG(3) << "Writing message (id=" | 137 DVLOG(3) << "Writing message (id=" |
| 138 << write_buffer_.front()->message->message_id() | 138 << write_buffer_.front()->message->message_id() << ", " |
| 139 << ", type=" << message_to_write->type() << ")"; | 139 << *message_to_write << ")"; |
| 140 | 140 |
| 141 output_processor_->ProcessMessage(std::move(message_to_write), | 141 output_processor_->ProcessMessage(std::move(message_to_write), |
| 142 write_complete_cb_.callback()); | 142 write_complete_cb_.callback()); |
| 143 DVLOG(3) << "Queue size: " << write_buffer_.size(); | 143 DVLOG(3) << "Queue size: " << write_buffer_.size(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void BlimpMessageOutputBuffer::OnWriteComplete(int result) { | 146 void BlimpMessageOutputBuffer::OnWriteComplete(int result) { |
| 147 DCHECK_LE(result, net::OK); | 147 DCHECK_LE(result, net::OK); |
| 148 VLOG(2) << "Write complete, result=" << result; | 148 VLOG(2) << "Write complete, result=" << result; |
| 149 | 149 |
| 150 if (result == net::OK) { | 150 if (result == net::OK) { |
| 151 ack_buffer_.push_back(std::move(write_buffer_.front())); | 151 ack_buffer_.push_back(std::move(write_buffer_.front())); |
| 152 write_buffer_.pop_front(); | 152 write_buffer_.pop_front(); |
| 153 WriteNextMessageIfReady(); | 153 WriteNextMessageIfReady(); |
| 154 } else { | 154 } else { |
| 155 // An error occurred while writing to the network connection. | 155 // An error occurred while writing to the network connection. |
| 156 // Stop writing more messages until a new connection is established. | 156 // Stop writing more messages until a new connection is established. |
| 157 DLOG(WARNING) << "Write error (result=" << result << ")"; | 157 DLOG(WARNING) << "Write error (result=" << result << ")"; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace blimp | 161 } // namespace blimp |
| OLD | NEW |