Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: components/test_runner/web_task.cc

Issue 1852603002: Replacing most of web_task.h with base::Closure + base::WeakPtrFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-mocks-to-test-runner
Patch Set: Rebasing... Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/test_runner/web_task.h ('k') | components/test_runner/web_test_interfaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/test_runner/web_task.h" 5 #include "components/test_runner/web_task.h"
6 6
7 #include <algorithm>
8
9 #include "third_party/WebKit/public/web/WebKit.h"
10
11 namespace test_runner { 7 namespace test_runner {
12 8
13 WebTask::WebTask(WebTaskList* list) : task_list_(list) { 9 WebCallbackTask::WebCallbackTask(const base::Closure& callback)
14 task_list_->RegisterTask(this); 10 : callback_(callback) {}
15 }
16 11
17 WebTask::~WebTask() { 12 WebCallbackTask::~WebCallbackTask() {}
18 if (task_list_)
19 task_list_->UnregisterTask(this);
20 }
21 13
22 WebTaskList::WebTaskList() { 14 void WebCallbackTask::run() {
23 } 15 callback_.Run();
24
25 WebTaskList::~WebTaskList() {
26 RevokeAll();
27 }
28
29 void WebTaskList::RegisterTask(WebTask* task) {
30 tasks_.push_back(task);
31 }
32
33 void WebTaskList::UnregisterTask(WebTask* task) {
34 std::vector<WebTask*>::iterator iter =
35 std::find(tasks_.begin(), tasks_.end(), task);
36 if (iter != tasks_.end())
37 tasks_.erase(iter);
38 }
39
40 void WebTaskList::RevokeAll() {
41 while (!tasks_.empty())
42 tasks_[0]->cancel();
43 } 16 }
44 17
45 } // namespace test_runner 18 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/web_task.h ('k') | components/test_runner/web_test_interfaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698