blob: dcb173396329e6330814747b2533e2ee44f90c93 [file] [log] [blame]
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "base/basictypes.h"
#include "base/message_loop/message_loop.h"
#include "base/pending_task.h"
namespace net {
// SpdySessionTestTaskObserver is a MessageLoop::TaskObserver that monitors the
// completion of all tasks executed by the current MessageLoop, recording the
// number of tasks that refer to a specific function and filename.
class SpdySessionTestTaskObserver : public base::MessageLoop::TaskObserver {
// Creates a SpdySessionTaskObserver that will record all tasks that are
// executed that were posted by the function named by |function_name|, located
// in the file |file_name|.
// Example:
// file_name = ""
// function = "DoFoo"
SpdySessionTestTaskObserver(const std::string& file_name,
const std::string& function_name);
~SpdySessionTestTaskObserver() override;
// Implements MessageLoop::TaskObserver.
void WillProcessTask(const base::PendingTask& pending_task) override;
void DidProcessTask(const base::PendingTask& pending_task) override;
// Returns the number of tasks posted by the given function and file.
uint16 executed_count() const { return executed_count_; }
uint16 executed_count_;
std::string file_name_;
std::string function_name_;
} // namespace net