| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_TEST_HOST_RESOLVER_OBSERVER_H_ | 5 #ifndef NET_BASE_TEST_HOST_RESOLVER_OBSERVER_H_ |
| 6 #define NET_BASE_TEST_HOST_RESOLVER_OBSERVER_H_ | 6 #define NET_BASE_TEST_HOST_RESOLVER_OBSERVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "net/base/host_resolver.h" | 9 #include "net/base/host_resolver.h" |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 bool operator==(const HostResolver::RequestInfo& a, | 15 bool operator==(const HostResolver::RequestInfo& a, |
| 16 const HostResolver::RequestInfo& b); | 16 const HostResolver::RequestInfo& b); |
| 17 | 17 |
| 18 // Observer that just makes note of how it was called. The test code can then | 18 // Observer that just makes note of how it was called. The test code can then |
| 19 // inspect to make sure it was called with the right parameters. Used by | 19 // inspect to make sure it was called with the right parameters. Used by |
| 20 // HostResolverImpl and AsyncHostResolver unit tests. | 20 // HostResolverImpl and AsyncHostResolver unit tests. |
| 21 class TestHostResolverObserver : public HostResolver::Observer { | 21 class TestHostResolverObserver : public HostResolver::Observer { |
| 22 public: | 22 public: |
| 23 TestHostResolverObserver(); | 23 TestHostResolverObserver(); |
| 24 virtual ~TestHostResolverObserver(); | 24 virtual ~TestHostResolverObserver(); |
| 25 | 25 |
| 26 // HostResolver::Observer methods: | 26 // HostResolver::Observer methods: |
| 27 virtual void OnStartResolution(int id, const HostResolver::RequestInfo& info); | 27 virtual void OnStartResolution( |
| 28 int id, |
| 29 const HostResolver::RequestInfo& info) OVERRIDE; |
| 28 virtual void OnFinishResolutionWithStatus( | 30 virtual void OnFinishResolutionWithStatus( |
| 29 int id, | 31 int id, |
| 30 bool was_resolved, | 32 bool was_resolved, |
| 31 const HostResolver::RequestInfo& info); | 33 const HostResolver::RequestInfo& info) OVERRIDE; |
| 32 virtual void OnCancelResolution( | 34 virtual void OnCancelResolution( |
| 33 int id, | 35 int id, |
| 34 const HostResolver::RequestInfo& info); | 36 const HostResolver::RequestInfo& info) OVERRIDE; |
| 35 | 37 |
| 36 // Tuple (id, info). | 38 // Tuple (id, info). |
| 37 struct StartOrCancelEntry { | 39 struct StartOrCancelEntry { |
| 38 StartOrCancelEntry(int id, const HostResolver::RequestInfo& info) | 40 StartOrCancelEntry(int id, const HostResolver::RequestInfo& info) |
| 39 : id(id), info(info) {} | 41 : id(id), info(info) {} |
| 40 | 42 |
| 41 bool operator==(const StartOrCancelEntry& other) const { | 43 bool operator==(const StartOrCancelEntry& other) const { |
| 42 return id == other.id && info == other.info; | 44 return id == other.id && info == other.info; |
| 43 } | 45 } |
| 44 | 46 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 std::vector<StartOrCancelEntry> start_log; | 68 std::vector<StartOrCancelEntry> start_log; |
| 67 std::vector<FinishEntry> finish_log; | 69 std::vector<FinishEntry> finish_log; |
| 68 std::vector<StartOrCancelEntry> cancel_log; | 70 std::vector<StartOrCancelEntry> cancel_log; |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 } // namespace net | 73 } // namespace net |
| 72 | 74 |
| 73 #endif // NET_BASE_TEST_HOST_RESOLVER_OBSERVER_H_ | 75 #endif // NET_BASE_TEST_HOST_RESOLVER_OBSERVER_H_ |
| OLD | NEW |