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

Side by Side Diff: blimp/net/test_common.cc

Issue 1825263003: Blimp: add packet-level DEFLATE compression using zlib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wez feedback Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « blimp/net/test_common.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « blimp/net/test_common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698