| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 MockBlimpMessageProcessor::~MockBlimpMessageProcessor() {} | 60 MockBlimpMessageProcessor::~MockBlimpMessageProcessor() {} |
| 61 | 61 |
| 62 void MockBlimpMessageProcessor::ProcessMessage( | 62 void MockBlimpMessageProcessor::ProcessMessage( |
| 63 scoped_ptr<BlimpMessage> message, | 63 scoped_ptr<BlimpMessage> message, |
| 64 const net::CompletionCallback& callback) { | 64 const net::CompletionCallback& callback) { |
| 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 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, const std::string& str) { |
| 76 return (static_cast<size_t>(buf->capacity()) > str.size() && | 76 return (static_cast<size_t>(buf->capacity()) > str.size() && |
| 77 str == std::string(buf->StartOfBuffer(), str.size())); | 77 str == std::string(buf->StartOfBuffer(), str.size())); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace blimp | 80 } // namespace blimp |
| OLD | NEW |