blob: 819b15c8da03ae3d6dea6c71c8f12a636305ba1c [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
Alexander Timin4f9c35c2018-11-01 20:15:2012#include "base/message_loop/message_loop.h"
[email protected]85f97342013-04-17 06:12:2413#include "base/pending_task.h"
14
15namespace net {
16
17// SpdySessionTestTaskObserver is a MessageLoop::TaskObserver that monitors the
18// completion of all tasks executed by the current MessageLoop, recording the
19// number of tasks that refer to a specific function and filename.
[email protected]2da659e2013-05-23 20:51:3420class SpdySessionTestTaskObserver : public base::MessageLoop::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
32 // Implements MessageLoop::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_