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.
5 #ifndef NET_SPDY_SPDY_SESSION_TEST_UTIL_H_
6 #define NET_SPDY_SPDY_SESSION_TEST_UTIL_H_
10 #include "base/basictypes.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/pending_task.h"
16 // SpdySessionTestTaskObserver is a MessageLoop::TaskObserver that monitors the
17 // completion of all tasks executed by the current MessageLoop, recording the
18 // number of tasks that refer to a specific function and filename.
19 class SpdySessionTestTaskObserver : public base::MessageLoop::TaskObserver {
21 // Creates a SpdySessionTaskObserver that will record all tasks that are
22 // executed that were posted by the function named by |function_name|, located
23 // in the file |file_name|.
25 // file_name = "foo.cc"
27 SpdySessionTestTaskObserver(const std::string& file_name,
28 const std::string& function_name);
29 ~SpdySessionTestTaskObserver() override;
31 // Implements MessageLoop::TaskObserver.
32 void WillProcessTask(const base::PendingTask& pending_task) override;
33 void DidProcessTask(const base::PendingTask& pending_task) override;
35 // Returns the number of tasks posted by the given function and file.
36 uint16 executed_count() const { return executed_count_; }
39 uint16 executed_count_;
40 std::string file_name_;
41 std::string function_name_;
46 #endif // NET_SPDY_SPDY_SESSION_TEST_UTIL_H_