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

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

Issue 1429193002: Add interfaces for most major Blimp net components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address wez's feedback. Created 5 years, 1 month 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
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/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
OLDNEW
« blimp/net/stream_socket_connection.h ('K') | « blimp/net/test_common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698