| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_TOOLS_QUIC_TEST_TOOLS_MOCK_EPOLL_SERVER_H_ | 5 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_MOCK_EPOLL_SERVER_H_ |
| 6 #define NET_TOOLS_QUIC_TEST_TOOLS_MOCK_EPOLL_SERVER_H_ | 6 #define NET_TOOLS_QUIC_TEST_TOOLS_MOCK_EPOLL_SERVER_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/tools/epoll_server/epoll_server.h" | 9 #include "net/tools/epoll_server/epoll_server.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // Note that the WaitForEventsAndExecuteCallbacks invocation | 36 // Note that the WaitForEventsAndExecuteCallbacks invocation |
| 37 // may cause NowInUs to advance beyond what was specified here. | 37 // may cause NowInUs to advance beyond what was specified here. |
| 38 // If that is not desired, use the AdvanceByExactly calls. | 38 // If that is not desired, use the AdvanceByExactly calls. |
| 39 void AdvanceByAndCallCallbacks(int64 advancement_usec) { | 39 void AdvanceByAndCallCallbacks(int64 advancement_usec) { |
| 40 AdvanceBy(advancement_usec); | 40 AdvanceBy(advancement_usec); |
| 41 WaitForEventsAndExecuteCallbacks(); | 41 WaitForEventsAndExecuteCallbacks(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 int64 now_in_usec_; | 45 int64 now_in_usec_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(FakeTimeEpollServer); |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 class MockEpollServer : public FakeTimeEpollServer { | 50 class MockEpollServer : public FakeTimeEpollServer { |
| 49 public: // type definitions | 51 public: // type definitions |
| 50 typedef base::hash_multimap<int64, struct epoll_event> EventQueue; | 52 typedef base::hash_multimap<int64, struct epoll_event> EventQueue; |
| 51 | 53 |
| 52 MockEpollServer(); | 54 MockEpollServer(); |
| 53 virtual ~MockEpollServer(); | 55 virtual ~MockEpollServer(); |
| 54 | 56 |
| 55 // time_in_usec is the time at which the event specified | 57 // time_in_usec is the time at which the event specified |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Replaces the epoll_server's epoll_wait_impl. | 92 // Replaces the epoll_server's epoll_wait_impl. |
| 91 virtual int epoll_wait_impl(int epfd, | 93 virtual int epoll_wait_impl(int epfd, |
| 92 struct epoll_event* events, | 94 struct epoll_event* events, |
| 93 int max_events, | 95 int max_events, |
| 94 int timeout_in_ms) OVERRIDE; | 96 int timeout_in_ms) OVERRIDE; |
| 95 virtual void SetNonblocking (int fd) OVERRIDE { } | 97 virtual void SetNonblocking (int fd) OVERRIDE { } |
| 96 | 98 |
| 97 private: // members | 99 private: // members |
| 98 EventQueue event_queue_; | 100 EventQueue event_queue_; |
| 99 int64 until_in_usec_; | 101 int64 until_in_usec_; |
| 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(MockEpollServer); |
| 100 }; | 104 }; |
| 101 | 105 |
| 102 } // namespace test | 106 } // namespace test |
| 103 } // namespace tools | 107 } // namespace tools |
| 104 } // namespace net | 108 } // namespace net |
| 105 | 109 |
| 106 #endif // NET_TOOLS_QUIC_TEST_TOOLS_MOCK_EPOLL_SERVER_H_ | 110 #endif // NET_TOOLS_QUIC_TEST_TOOLS_MOCK_EPOLL_SERVER_H_ |
| OLD | NEW |