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

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

Issue 1349783006: Cleanup: Pass std::string as const reference if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert third_party changes Created 5 years, 3 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
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 "base/location.h" 7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 18 matching lines...) Expand all
29 return SendToInternal(std::string(buf->data(), buf_len), address.ToString(), 29 return SendToInternal(std::string(buf->data(), buf_len), address.ToString(),
30 callback); 30 callback);
31 } 31 }
32 32
33 int MockMDnsDatagramServerSocket::GetLocalAddress(IPEndPoint* address) const { 33 int MockMDnsDatagramServerSocket::GetLocalAddress(IPEndPoint* address) const {
34 *address = local_address_; 34 *address = local_address_;
35 return OK; 35 return OK;
36 } 36 }
37 37
38 void MockMDnsDatagramServerSocket::SetResponsePacket( 38 void MockMDnsDatagramServerSocket::SetResponsePacket(
39 std::string response_packet) { 39 const std::string& response_packet) {
40 response_packet_ = response_packet; 40 response_packet_ = response_packet;
41 } 41 }
42 42
43 int MockMDnsDatagramServerSocket::HandleRecvNow( 43 int MockMDnsDatagramServerSocket::HandleRecvNow(
44 IOBuffer* buffer, int size, IPEndPoint* address, 44 IOBuffer* buffer, int size, IPEndPoint* address,
45 const CompletionCallback& callback) { 45 const CompletionCallback& callback) {
46 int size_returned = 46 int size_returned =
47 std::min(response_packet_.size(), static_cast<size_t>(size)); 47 std::min(response_packet_.size(), static_cast<size_t>(size));
48 memcpy(buffer->data(), response_packet_.data(), size_returned); 48 memcpy(buffer->data(), response_packet_.data(), size_returned);
49 return size_returned; 49 return size_returned;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 int MockMDnsSocketFactory::SendToInternal( 113 int MockMDnsSocketFactory::SendToInternal(
114 const std::string& packet, const std::string& address, 114 const std::string& packet, const std::string& address,
115 const CompletionCallback& callback) { 115 const CompletionCallback& callback) {
116 OnSendTo(packet); 116 OnSendTo(packet);
117 return packet.size(); 117 return packet.size();
118 } 118 }
119 119
120 } // namespace net 120 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698