OLD | NEW |
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 #ifndef NET_DNS_MOCK_MDNS_SOCKET_FACTORY_H_ | 5 #ifndef NET_DNS_MOCK_MDNS_SOCKET_FACTORY_H_ |
6 #define NET_DNS_MOCK_MDNS_SOCKET_FACTORY_H_ | 6 #define NET_DNS_MOCK_MDNS_SOCKET_FACTORY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "net/dns/mdns_client_impl.h" | 10 #include "net/dns/mdns_client_impl.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 }; | 70 }; |
71 | 71 |
72 class MockMDnsSocketFactory : public MDnsConnection::SocketFactory { | 72 class MockMDnsSocketFactory : public MDnsConnection::SocketFactory { |
73 public: | 73 public: |
74 MockMDnsSocketFactory(); | 74 MockMDnsSocketFactory(); |
75 | 75 |
76 virtual ~MockMDnsSocketFactory(); | 76 virtual ~MockMDnsSocketFactory(); |
77 | 77 |
78 virtual scoped_ptr<DatagramServerSocket> CreateSocket() OVERRIDE; | 78 virtual scoped_ptr<DatagramServerSocket> CreateSocket() OVERRIDE; |
79 | 79 |
80 void SimulateReceive(const char* packet, int size); | 80 void SimulateReceive(const uint8* packet, int size); |
81 | 81 |
82 MOCK_METHOD1(OnSendTo, void(const std::string&)); | 82 MOCK_METHOD1(OnSendTo, void(const std::string&)); |
83 | 83 |
84 private: | 84 private: |
85 int SendToInternal(const std::string& packet, const std::string& address, | 85 int SendToInternal(const std::string& packet, const std::string& address, |
86 const CompletionCallback& callback); | 86 const CompletionCallback& callback); |
87 | 87 |
88 // The latest receive callback is always saved, since the MDnsConnection | 88 // The latest receive callback is always saved, since the MDnsConnection |
89 // does not care which socket a packet is received on. | 89 // does not care which socket a packet is received on. |
90 int RecvFromInternal(IOBuffer* buffer, int size, | 90 int RecvFromInternal(IOBuffer* buffer, int size, |
91 IPEndPoint* address, | 91 IPEndPoint* address, |
92 const CompletionCallback& callback); | 92 const CompletionCallback& callback); |
93 | 93 |
94 scoped_refptr<IOBuffer> recv_buffer_; | 94 scoped_refptr<IOBuffer> recv_buffer_; |
95 int recv_buffer_size_; | 95 int recv_buffer_size_; |
96 CompletionCallback recv_callback_; | 96 CompletionCallback recv_callback_; |
97 }; | 97 }; |
98 | 98 |
99 } // namespace net | 99 } // namespace net |
100 | 100 |
101 #endif // NET_DNS_MOCK_MDNS_SOCKET_FACTORY_H_ | 101 #endif // NET_DNS_MOCK_MDNS_SOCKET_FACTORY_H_ |
OLD | NEW |