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

Unified Diff: content/shell/renderer/test_runner/web_task.cc

Issue 566833002: Update WebTask in chromium c++ style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/renderer/test_runner/web_task.cc
diff --git a/content/shell/renderer/test_runner/web_task.cc b/content/shell/renderer/test_runner/web_task.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8fa9d6d281bd65988899f6d30bb9ae8ef529ea5e
--- /dev/null
+++ b/content/shell/renderer/test_runner/web_task.cc
@@ -0,0 +1,44 @@
+// Copyright 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 "content/shell/renderer/test_runner/web_task.h"
+
+#include <algorithm>
+#include "third_party/WebKit/public/web/WebKit.h"
jochen (gone - plz use gerrit) 2014/09/12 07:47:03 nit. empty line between system headers and other h
Abhishek 2014/09/12 08:00:09 Done.
+
+namespace content {
+
+WebTask::WebTask(WebTaskList* list) : task_list_(list) {
+ task_list_->RegisterTask(this);
+}
+
+WebTask::~WebTask() {
+ if (task_list_)
+ task_list_->UnregisterTask(this);
+}
+
+WebTaskList::WebTaskList() {
+}
+
+WebTaskList::~WebTaskList() {
+ RevokeAll();
+}
+
+void WebTaskList::RegisterTask(WebTask* task) {
+ tasks_.push_back(task);
+}
+
+void WebTaskList::UnregisterTask(WebTask* task) {
+ std::vector<WebTask*>::iterator iter =
+ std::find(tasks_.begin(), tasks_.end(), task);
+ if (iter != tasks_.end())
+ tasks_.erase(iter);
+}
+
+void WebTaskList::RevokeAll() {
+ while (!tasks_.empty())
+ tasks_[0]->cancel();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698