| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DNS_MOCK_HOST_RESOLVER_CREATOR_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DNS_MOCK_HOST_RESOLVER_CREATOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/synchronization/waitable_event.h" |
| 13 |
| 14 namespace net { |
| 15 class MockHostResolver; |
| 16 } |
| 17 |
| 18 namespace extensions { |
| 19 |
| 20 // Used only for testing. Creates a MockHostResolver, respecting threading |
| 21 // constraints. |
| 22 class MockHostResolverCreator |
| 23 : public base::RefCountedThreadSafe<MockHostResolverCreator> { |
| 24 public: |
| 25 static const std::string kHostname; |
| 26 static const std::string kAddress; |
| 27 |
| 28 MockHostResolverCreator(); |
| 29 virtual ~MockHostResolverCreator(); |
| 30 |
| 31 net::MockHostResolver* CreateMockHostResolver(); |
| 32 void DeleteMockHostResolver(); |
| 33 |
| 34 private: |
| 35 void CreateMockHostResolverOnIOThread(); |
| 36 void DeleteMockHostResolverOnIOThread(); |
| 37 |
| 38 base::WaitableEvent resolver_event_; |
| 39 |
| 40 // The MockHostResolver asserts that it's used on the same thread on which |
| 41 // it's created, which is actually a stronger rule than its real counterpart. |
| 42 // But that's fine; it's good practice. |
| 43 // |
| 44 // Plain pointer because we have to manage lifetime manually. |
| 45 net::MockHostResolver* mock_host_resolver_; |
| 46 }; |
| 47 |
| 48 } // namespace extensions |
| 49 |
| 50 #endif // CHROME_BROWSER_EXTENSIONS_API_DNS_MOCK_HOST_RESOLVER_CREATOR_H_ |
| OLD | NEW |