Roll forward to cl/345608764.

Signed-off-by: hai007 <hais@google.com>
This commit is contained in:
hai007
2020-12-03 22:36:42 -08:00
parent e6d52359cf
commit 873548acaa
22 changed files with 511 additions and 252 deletions
+12 -1
View File
@@ -2,6 +2,7 @@
#include <algorithm>
#include <cinttypes>
#include <limits>
#include <memory>
#include <string>
#include <utility>
@@ -75,8 +76,9 @@ bool PayloadManager::SendPayloadLoop(
// This will block if there is no data to transfer.
// It will resume when new data arrives, or if Close() is called.
int chunk_size = GetOptimalChunkSize(available_endpoint_ids);
ByteArray next_chunk =
pending_payload.GetInternalPayload()->DetachNextChunk();
pending_payload.GetInternalPayload()->DetachNextChunk(chunk_size);
if (shutdown_.Get()) return false;
// Save chunk size. We'll need it after we move next_chunk.
auto next_chunk_size = next_chunk.size();
@@ -483,6 +485,15 @@ SingleThreadExecutor* PayloadManager::GetOutgoingPayloadExecutor(
}
}
int PayloadManager::GetOptimalChunkSize(EndpointIds endpoint_ids) {
int minChunkSize = std::numeric_limits<int>::max();
for (const auto& endpoint_id : endpoint_ids) {
minChunkSize = std::min(
minChunkSize, endpoint_manager_->GetMaxTransmitPacketSize(endpoint_id));
}
return minChunkSize;
}
PayloadTransferFrame::PayloadHeader PayloadManager::CreatePayloadHeader(
const InternalPayload& internal_payload) {
PayloadTransferFrame::PayloadHeader payload_header;