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 using namespace std; 11 12 namespace content { 13 WebTask(WebTaskList * list)14WebTask::WebTask(WebTaskList* list) 15 : m_taskList(list) 16 { 17 m_taskList->registerTask(this); 18 } 19 ~WebTask()20WebTask::~WebTask() 21 { 22 if (m_taskList) 23 m_taskList->unregisterTask(this); 24 } 25 WebTaskList()26WebTaskList::WebTaskList() 27 { 28 } 29 ~WebTaskList()30WebTaskList::~WebTaskList() 31 { 32 revokeAll(); 33 } 34 registerTask(WebTask * task)35void WebTaskList::registerTask(WebTask* task) 36 { 37 m_tasks.push_back(task); 38 } 39 unregisterTask(WebTask * task)40void WebTaskList::unregisterTask(WebTask* task) 41 { 42 vector<WebTask*>::iterator iter = find(m_tasks.begin(), m_tasks.end(), task); 43 if (iter != m_tasks.end()) 44 m_tasks.erase(iter); 45 } 46 revokeAll()47void WebTaskList::revokeAll() 48 { 49 while (!m_tasks.empty()) 50 m_tasks[0]->cancel(); 51 } 52 53 } // namespace content 54