OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "blimp/net/message_port.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/memory/ptr_util.h" | |
10 #include "blimp/net/compressed_packet_reader.h" | |
11 #include "blimp/net/compressed_packet_writer.h" | |
12 #include "blimp/net/packet_reader.h" | |
13 #include "blimp/net/packet_writer.h" | |
14 #include "blimp/net/stream_packet_reader.h" | |
15 #include "blimp/net/stream_packet_writer.h" | |
16 #include "net/socket/stream_socket.h" | |
17 | |
18 namespace blimp { | |
19 namespace { | |
20 | |
21 class CompressedStreamSocketMessagePort : public MessagePort { | |
22 public: | |
23 explicit CompressedStreamSocketMessagePort( | |
24 std::unique_ptr<net::StreamSocket> socket); | |
25 ~CompressedStreamSocketMessagePort() override {} | |
26 | |
27 private: | |
28 std::unique_ptr<net::StreamSocket> socket_; | |
29 | |
30 DISALLOW_COPY_AND_ASSIGN(CompressedStreamSocketMessagePort); | |
31 }; | |
32 | |
33 CompressedStreamSocketMessagePort::CompressedStreamSocketMessagePort( | |
34 std::unique_ptr<net::StreamSocket> socket) | |
35 : MessagePort(base::MakeUnique<CompressedPacketReader>( | |
36 base::MakeUnique<StreamPacketReader>(socket.get())), | |
37 base::MakeUnique<CompressedPacketWriter>( | |
38 base::MakeUnique<StreamPacketWriter>(socket.get()))), | |
39 socket_(std::move(socket)) {} | |
40 | |
41 } // namespace | |
42 | |
43 // static | |
44 std::unique_ptr<MessagePort> MessagePort::CreateForStreamSocketWithCompression( | |
45 std::unique_ptr<net::StreamSocket> socket) { | |
46 return base::MakeUnique<CompressedStreamSocketMessagePort>(std::move(socket)); | |
47 } | |
48 | |
49 MessagePort::MessagePort(std::unique_ptr<PacketReader> reader, | |
50 std::unique_ptr<PacketWriter> writer) | |
51 : reader_(std::move(reader)), writer_(std::move(writer)) {} | |
52 | |
53 MessagePort::~MessagePort() {} | |
54 | |
55 } // namespace blimp | |
OLD | NEW |