[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 1 | // Copyright (c) 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. | ||||
4 | |||||
Bence Béky | 94658bf | 2018-05-11 19:22:58 | [diff] [blame] | 5 | #ifndef NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ |
6 | #define NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ | ||||
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 7 | |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 8 | #include <stdint.h> |
9 | |||||
Bence Béky | 4e83f49 | 2018-05-13 23:14:25 | [diff] [blame] | 10 | #include <string> |
11 | |||||
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 12 | #include "base/pending_task.h" |
Carlos Caballero | feae87148 | 2019-08-12 14:14:43 | [diff] [blame] | 13 | #include "base/task/task_observer.h" |
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 14 | |
15 | namespace net { | ||||
16 | |||||
Carlos Caballero | feae87148 | 2019-08-12 14:14:43 | [diff] [blame] | 17 | // SpdySessionTestTaskObserver is a TaskObserver that monitors the |
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 18 | // completion of all tasks executed by the current MessageLoop, recording the |
19 | // number of tasks that refer to a specific function and filename. | ||||
Carlos Caballero | feae87148 | 2019-08-12 14:14:43 | [diff] [blame] | 20 | class SpdySessionTestTaskObserver : public base::TaskObserver { |
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 21 | public: |
22 | // Creates a SpdySessionTaskObserver that will record all tasks that are | ||||
23 | // executed that were posted by the function named by |function_name|, located | ||||
24 | // in the file |file_name|. | ||||
25 | // Example: | ||||
26 | // file_name = "foo.cc" | ||||
27 | // function = "DoFoo" | ||||
Bence Béky | 4e83f49 | 2018-05-13 23:14:25 | [diff] [blame] | 28 | SpdySessionTestTaskObserver(const std::string& file_name, |
29 | const std::string& function_name); | ||||
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 30 | ~SpdySessionTestTaskObserver() override; |
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 31 | |
Carlos Caballero | feae87148 | 2019-08-12 14:14:43 | [diff] [blame] | 32 | // Implements TaskObserver. |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 33 | void WillProcessTask(const base::PendingTask& pending_task) override; |
34 | void DidProcessTask(const base::PendingTask& pending_task) override; | ||||
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 35 | |
36 | // Returns the number of tasks posted by the given function and file. | ||||
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 37 | uint16_t executed_count() const { return executed_count_; } |
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 38 | |
39 | private: | ||||
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 40 | uint16_t executed_count_; |
Bence Béky | 4e83f49 | 2018-05-13 23:14:25 | [diff] [blame] | 41 | std::string file_name_; |
42 | std::string function_name_; | ||||
[email protected] | 85f9734 | 2013-04-17 06:12:24 | [diff] [blame] | 43 | }; |
44 | |||||
45 | } // namespace net | ||||
46 | |||||
Bence Béky | 94658bf | 2018-05-11 19:22:58 | [diff] [blame] | 47 | #endif // NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ |