blob: 2bdec6d12888f2574a2feb854cb223950d7e0d3d [file] [log] [blame]
[email protected]85f97342013-04-17 06:12:241// 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éky94658bf2018-05-11 19:22:585#ifndef NET_SPDY_SPDY_SESSION_TEST_UTIL_H_
6#define NET_SPDY_SPDY_SESSION_TEST_UTIL_H_
[email protected]85f97342013-04-17 06:12:247
Avi Drissman13fc8932015-12-20 04:40:468#include <stdint.h>
9
Bence Béky4e83f492018-05-13 23:14:2510#include <string>
11
[email protected]85f97342013-04-17 06:12:2412#include "base/pending_task.h"
Carlos Caballerofeae871482019-08-12 14:14:4313#include "base/task/task_observer.h"
[email protected]85f97342013-04-17 06:12:2414
15namespace net {
16
Carlos Caballerofeae871482019-08-12 14:14:4317// SpdySessionTestTaskObserver is a TaskObserver that monitors the
[email protected]85f97342013-04-17 06:12:2418// completion of all tasks executed by the current MessageLoop, recording the
19// number of tasks that refer to a specific function and filename.
Carlos Caballerofeae871482019-08-12 14:14:4320class SpdySessionTestTaskObserver : public base::TaskObserver {
[email protected]85f97342013-04-17 06:12:2421 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éky4e83f492018-05-13 23:14:2528 SpdySessionTestTaskObserver(const std::string& file_name,
29 const std::string& function_name);
dchengb03027d2014-10-21 12:00:2030 ~SpdySessionTestTaskObserver() override;
[email protected]85f97342013-04-17 06:12:2431
Carlos Caballerofeae871482019-08-12 14:14:4332 // Implements TaskObserver.
dchengb03027d2014-10-21 12:00:2033 void WillProcessTask(const base::PendingTask& pending_task) override;
34 void DidProcessTask(const base::PendingTask& pending_task) override;
[email protected]85f97342013-04-17 06:12:2435
36 // Returns the number of tasks posted by the given function and file.
Avi Drissman13fc8932015-12-20 04:40:4637 uint16_t executed_count() const { return executed_count_; }
[email protected]85f97342013-04-17 06:12:2438
39 private:
Avi Drissman13fc8932015-12-20 04:40:4640 uint16_t executed_count_;
Bence Béky4e83f492018-05-13 23:14:2541 std::string file_name_;
42 std::string function_name_;
[email protected]85f97342013-04-17 06:12:2443};
44
45} // namespace net
46
Bence Béky94658bf2018-05-11 19:22:5847#endif // NET_SPDY_SPDY_SESSION_TEST_UTIL_H_