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

Side by Side Diff: net/dns/mock_mdns_socket_factory.cc

Issue 21534003: avoid char+'\xHH' as it's too easy to use values > 127 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: corresponding change in chrome unit tests Created 7 years, 4 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 | « net/dns/mock_mdns_socket_factory.h ('k') | net/dns/record_parsed_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/dns/mock_mdns_socket_factory.h" 8 #include "net/dns/mock_mdns_socket_factory.h"
9 9
10 using testing::_; 10 using testing::_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 &MockMDnsSocketFactory::SendToInternal)); 77 &MockMDnsSocketFactory::SendToInternal));
78 78
79 ON_CALL(*new_socket, RecvFrom(_, _, _, _)) 79 ON_CALL(*new_socket, RecvFrom(_, _, _, _))
80 .WillByDefault(Invoke( 80 .WillByDefault(Invoke(
81 this, 81 this,
82 &MockMDnsSocketFactory::RecvFromInternal)); 82 &MockMDnsSocketFactory::RecvFromInternal));
83 83
84 return new_socket.PassAs<DatagramServerSocket>(); 84 return new_socket.PassAs<DatagramServerSocket>();
85 } 85 }
86 86
87 void MockMDnsSocketFactory::SimulateReceive(const char* packet, int size) { 87 void MockMDnsSocketFactory::SimulateReceive(const uint8* packet, int size) {
88 DCHECK(recv_buffer_size_ >= size); 88 DCHECK(recv_buffer_size_ >= size);
89 DCHECK(recv_buffer_.get()); 89 DCHECK(recv_buffer_.get());
90 DCHECK(!recv_callback_.is_null()); 90 DCHECK(!recv_callback_.is_null());
91 91
92 memcpy(recv_buffer_->data(), packet, size); 92 memcpy(recv_buffer_->data(), packet, size);
93 CompletionCallback recv_callback = recv_callback_; 93 CompletionCallback recv_callback = recv_callback_;
94 recv_callback_.Reset(); 94 recv_callback_.Reset();
95 recv_callback.Run(size); 95 recv_callback.Run(size);
96 } 96 }
97 97
98 int MockMDnsSocketFactory::RecvFromInternal( 98 int MockMDnsSocketFactory::RecvFromInternal(
99 IOBuffer* buffer, int size, 99 IOBuffer* buffer, int size,
100 IPEndPoint* address, 100 IPEndPoint* address,
101 const CompletionCallback& callback) { 101 const CompletionCallback& callback) {
102 recv_buffer_ = buffer; 102 recv_buffer_ = buffer;
103 recv_buffer_size_ = size; 103 recv_buffer_size_ = size;
104 recv_callback_ = callback; 104 recv_callback_ = callback;
105 return ERR_IO_PENDING; 105 return ERR_IO_PENDING;
106 } 106 }
107 107
108 int MockMDnsSocketFactory::SendToInternal( 108 int MockMDnsSocketFactory::SendToInternal(
109 const std::string& packet, const std::string& address, 109 const std::string& packet, const std::string& address,
110 const CompletionCallback& callback) { 110 const CompletionCallback& callback) {
111 OnSendTo(packet); 111 OnSendTo(packet);
112 return packet.size(); 112 return packet.size();
113 } 113 }
114 114
115 } // namespace net 115 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/mock_mdns_socket_factory.h ('k') | net/dns/record_parsed_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698