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

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

Issue 2462183002: GRPC Stream implementation of HeliumStream
Patch Set: Address gcasto comments Created 4 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
« 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 MockConnectionErrorObserver::~MockConnectionErrorObserver() {} 64 MockConnectionErrorObserver::~MockConnectionErrorObserver() {}
65 65
66 MockBlimpMessageProcessor::MockBlimpMessageProcessor() {} 66 MockBlimpMessageProcessor::MockBlimpMessageProcessor() {}
67 67
68 MockBlimpMessageProcessor::~MockBlimpMessageProcessor() {} 68 MockBlimpMessageProcessor::~MockBlimpMessageProcessor() {}
69 69
70 void MockBlimpMessageProcessor::ProcessMessage( 70 void MockBlimpMessageProcessor::ProcessMessage(
71 std::unique_ptr<BlimpMessage> message, 71 std::unique_ptr<BlimpMessage> message,
72 const net::CompletionCallback& callback) { 72 const net::CompletionCallback& callback) {
73 if (!test_callback_.is_null()) {
74 test_callback_.Run(net::OK);
75 }
76 received_msg = *message;
73 MockableProcessMessage(*message, callback); 77 MockableProcessMessage(*message, callback);
74 } 78 }
75 79
80 void MockBlimpMessageProcessor::SetTestCompletionCallback(
81 const net::CompletionCallback& callback) {
82 test_callback_ = callback;
83 }
84
76 std::string EncodeHeader(size_t size) { 85 std::string EncodeHeader(size_t size) {
77 std::unique_ptr<char[]> serialized(new char[kPacketHeaderSizeBytes]); 86 std::unique_ptr<char[]> serialized(new char[kPacketHeaderSizeBytes]);
78 uint32_t net_size = base::HostToNet32(size); 87 uint32_t net_size = base::HostToNet32(size);
79 memcpy(serialized.get(), &net_size, sizeof(net_size)); 88 memcpy(serialized.get(), &net_size, sizeof(net_size));
80 return std::string(serialized.get(), kPacketHeaderSizeBytes); 89 return std::string(serialized.get(), kPacketHeaderSizeBytes);
81 } 90 }
82 91
83 bool BufferStartsWith(net::GrowableIOBuffer* buf, 92 bool BufferStartsWith(net::GrowableIOBuffer* buf,
84 size_t buf_size, 93 size_t buf_size,
85 const std::string& str) { 94 const std::string& str) {
86 return (buf_size >= str.size() && 95 return (buf_size >= str.size() &&
87 str == std::string(buf->data(), str.size())); 96 str == std::string(buf->data(), str.size()));
88 } 97 }
89 98
90 } // namespace blimp 99 } // 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