| 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/test_common.h" | 5 #include "blimp/net/test_common.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/sys_byteorder.h" | 9 #include "base/sys_byteorder.h" |
| 10 #include "blimp/common/proto/blimp_message.pb.h" |
| 10 #include "blimp/net/common.h" | 11 #include "blimp/net/common.h" |
| 11 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 12 | 13 |
| 13 namespace blimp { | 14 namespace blimp { |
| 14 | 15 |
| 15 MockStreamSocket::MockStreamSocket() {} | 16 MockStreamSocket::MockStreamSocket() {} |
| 16 | 17 |
| 17 MockStreamSocket::~MockStreamSocket() {} | 18 MockStreamSocket::~MockStreamSocket() {} |
| 18 | 19 |
| 20 MockBlimpMessageProcessor::MockBlimpMessageProcessor() {} |
| 21 |
| 22 MockBlimpMessageProcessor::~MockBlimpMessageProcessor() {} |
| 23 |
| 19 std::string EncodeHeader(size_t size) { | 24 std::string EncodeHeader(size_t size) { |
| 20 scoped_ptr<char[]> serialized(new char[kPacketHeaderSizeBytes]); | 25 scoped_ptr<char[]> serialized(new char[kPacketHeaderSizeBytes]); |
| 21 uint32 net_size = base::HostToNet32(size); | 26 uint32 net_size = base::HostToNet32(size); |
| 22 memcpy(serialized.get(), &net_size, sizeof(net_size)); | 27 memcpy(serialized.get(), &net_size, sizeof(net_size)); |
| 23 return std::string(serialized.get(), kPacketHeaderSizeBytes); | 28 return std::string(serialized.get(), kPacketHeaderSizeBytes); |
| 24 } | 29 } |
| 25 | 30 |
| 26 bool BufferStartsWith(net::GrowableIOBuffer* buf, const std::string& str) { | 31 bool BufferStartsWith(net::GrowableIOBuffer* buf, const std::string& str) { |
| 27 return (static_cast<size_t>(buf->capacity()) > str.size() && | 32 return (static_cast<size_t>(buf->capacity()) > str.size() && |
| 28 str == std::string(buf->StartOfBuffer(), str.size())); | 33 str == std::string(buf->StartOfBuffer(), str.size())); |
| 29 } | 34 } |
| 30 | 35 |
| 31 } // namespace blimp | 36 } // namespace blimp |
| OLD | NEW |