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/common/proto/blimp_message.pb.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 MockableProcessMessage(*message, callback); | 65 MockableProcessMessage(*message, callback); |
66 } | 66 } |
67 | 67 |
68 std::string EncodeHeader(size_t size) { | 68 std::string EncodeHeader(size_t size) { |
69 scoped_ptr<char[]> serialized(new char[kPacketHeaderSizeBytes]); | 69 scoped_ptr<char[]> serialized(new char[kPacketHeaderSizeBytes]); |
70 uint32_t net_size = base::HostToNet32(size); | 70 uint32_t net_size = base::HostToNet32(size); |
71 memcpy(serialized.get(), &net_size, sizeof(net_size)); | 71 memcpy(serialized.get(), &net_size, sizeof(net_size)); |
72 return std::string(serialized.get(), kPacketHeaderSizeBytes); | 72 return std::string(serialized.get(), kPacketHeaderSizeBytes); |
73 } | 73 } |
74 | 74 |
75 bool BufferStartsWith(net::GrowableIOBuffer* buf, const std::string& str) { | 75 bool BufferStartsWith(net::GrowableIOBuffer* buf, |
76 return (static_cast<size_t>(buf->capacity()) > str.size() && | 76 size_t buf_size, |
77 str == std::string(buf->StartOfBuffer(), str.size())); | 77 const std::string& str) { |
| 78 return (buf_size >= str.size() && |
| 79 str == std::string(buf->data(), str.size())); |
78 } | 80 } |
79 | 81 |
80 } // namespace blimp | 82 } // namespace blimp |
OLD | NEW |