OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "content/shell/renderer/test_runner/WebTask.h" | |
6 | |
7 #include <algorithm> | |
8 #include "third_party/WebKit/public/web/WebKit.h" | |
9 | |
10 namespace content { | |
11 | |
12 WebTask::WebTask(WebTaskList* list) | |
13 : m_taskList(list) | |
14 { | |
15 m_taskList->registerTask(this); | |
16 } | |
17 | |
18 WebTask::~WebTask() | |
19 { | |
20 if (m_taskList) | |
21 m_taskList->unregisterTask(this); | |
22 } | |
23 | |
24 WebTaskList::WebTaskList() | |
25 { | |
26 } | |
27 | |
28 WebTaskList::~WebTaskList() | |
29 { | |
30 revokeAll(); | |
31 } | |
32 | |
33 void WebTaskList::registerTask(WebTask* task) | |
34 { | |
35 m_tasks.push_back(task); | |
36 } | |
37 | |
38 void WebTaskList::unregisterTask(WebTask* task) | |
39 { | |
40 std::vector<WebTask*>::iterator iter = std::find(m_tasks.begin(), m_tasks.en
d(), task); | |
41 if (iter != m_tasks.end()) | |
42 m_tasks.erase(iter); | |
43 } | |
44 | |
45 void WebTaskList::revokeAll() | |
46 { | |
47 while (!m_tasks.empty()) | |
48 m_tasks[0]->cancel(); | |
49 } | |
50 | |
51 } // namespace content | |
OLD | NEW |