Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: blimp/net/message_port.cc

Issue 2236093002: Decouple Blimp transport output from BlimpConnections using MessagePort. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@statistics-singleton
Patch Set: wez feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « blimp/net/message_port.h ('k') | blimp/net/ssl_client_transport_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/net/message_port.cc
diff --git a/blimp/net/message_port.cc b/blimp/net/message_port.cc
new file mode 100644
index 0000000000000000000000000000000000000000..039abdb642bc411ffc270905efa6d1e925e9a1dd
--- /dev/null
+++ b/blimp/net/message_port.cc
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/net/message_port.h"
+
+#include <utility>
+
+#include "base/memory/ptr_util.h"
+#include "blimp/net/compressed_packet_reader.h"
+#include "blimp/net/compressed_packet_writer.h"
+#include "blimp/net/packet_reader.h"
+#include "blimp/net/packet_writer.h"
+#include "blimp/net/stream_packet_reader.h"
+#include "blimp/net/stream_packet_writer.h"
+#include "net/socket/stream_socket.h"
+
+namespace blimp {
+namespace {
+
+class CompressedStreamSocketMessagePort : public MessagePort {
+ public:
+ explicit CompressedStreamSocketMessagePort(
+ std::unique_ptr<net::StreamSocket> socket);
+ ~CompressedStreamSocketMessagePort() override {}
+
+ private:
+ std::unique_ptr<net::StreamSocket> socket_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompressedStreamSocketMessagePort);
+};
+
+CompressedStreamSocketMessagePort::CompressedStreamSocketMessagePort(
+ std::unique_ptr<net::StreamSocket> socket)
+ : MessagePort(base::MakeUnique<CompressedPacketReader>(
+ base::MakeUnique<StreamPacketReader>(socket.get())),
+ base::MakeUnique<CompressedPacketWriter>(
+ base::MakeUnique<StreamPacketWriter>(socket.get()))),
+ socket_(std::move(socket)) {}
+
+} // namespace
+
+// static
+std::unique_ptr<MessagePort> MessagePort::CreateForStreamSocketWithCompression(
+ std::unique_ptr<net::StreamSocket> socket) {
+ return base::MakeUnique<CompressedStreamSocketMessagePort>(std::move(socket));
+}
+
+MessagePort::MessagePort(std::unique_ptr<PacketReader> reader,
+ std::unique_ptr<PacketWriter> writer)
+ : reader_(std::move(reader)), writer_(std::move(writer)) {}
+
+MessagePort::~MessagePort() {}
+
+} // namespace blimp
« no previous file with comments | « blimp/net/message_port.h ('k') | blimp/net/ssl_client_transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698