Refactor SharedMemory::Create and fix a rare file leak.
[chromium-blink-merge.git] / chrome / browser / local_discovery / test_service_discovery_client.h
blobcaf5eec45e40a9be21fa069038c229917c7101bd
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_TEST_SERVICE_DISCOVERY_CLIENT_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_TEST_SERVICE_DISCOVERY_CLIENT_H_
8 #include "chrome/browser/local_discovery/service_discovery_shared_client.h"
9 #include "chrome/common/local_discovery/service_discovery_client.h"
10 #include "net/dns/mdns_client.h"
11 #include "net/dns/mock_mdns_socket_factory.h"
12 #include "testing/gmock/include/gmock/gmock.h"
14 namespace local_discovery {
16 class TestServiceDiscoveryClient : public ServiceDiscoverySharedClient {
17 public:
18 TestServiceDiscoveryClient();
20 void Start();
22 scoped_ptr<ServiceWatcher> CreateServiceWatcher(
23 const std::string& service_type,
24 const ServiceWatcher::UpdatedCallback& callback) override;
25 scoped_ptr<ServiceResolver> CreateServiceResolver(
26 const std::string& service_name,
27 const ServiceResolver::ResolveCompleteCallback& callback) override;
28 scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver(
29 const std::string& domain,
30 net::AddressFamily address_family,
31 const LocalDomainResolver::IPAddressCallback& callback) override;
33 MOCK_METHOD1(OnSendTo, void(const std::string& data));
35 void SimulateReceive(const uint8* packet, int size);
37 private:
38 ~TestServiceDiscoveryClient() override;
40 // Owned by mdns_client_impl_.
41 net::MockMDnsSocketFactory mock_socket_factory_;
42 scoped_ptr<net::MDnsClient> mdns_client_;
43 scoped_ptr<ServiceDiscoveryClient> service_discovery_client_impl_;
46 } // namespace local_discovery
48 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_TEST_SERVICE_DISCOVERY_CLIENT_H_