1 // Copyright 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 CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTASK_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTASK_H_
10 namespace WebTestRunner
{
14 // WebTask represents a task which can run by WebTestDelegate::postTask() or
15 // WebTestDelegate::postDelayedTask().
18 explicit WebTask(WebTaskList
*);
21 // The main code of this task.
22 // An implementation of run() should return immediately if cancel() was called.
23 virtual void run() = 0;
24 virtual void cancel() = 0;
27 WebTaskList
* m_taskList
;
34 void registerTask(WebTask
*);
35 void unregisterTask(WebTask
*);
39 std::vector
<WebTask
*> m_tasks
;
42 // A task containing an object pointer of class T. Derived classes should
43 // override runIfValid() which in turn can safely invoke methods on the
44 // m_object. The Class T must have "WebTaskList* taskList()".
46 class WebMethodTask
: public WebTask
{
48 explicit WebMethodTask(T
* object
)
49 : WebTask(object
->taskList())
54 virtual ~WebMethodTask() { }
65 m_taskList
->unregisterTask(this);
69 virtual void runIfValid() = 0;
77 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTASK_H_