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

Unified Diff: webkit/glue/webthread_impl.cc

Issue 7600016: WebKitClient::createThread and associated implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For the trybots Created 9 years, 4 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
« no previous file with comments | « webkit/glue/webthread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webthread_impl.cc
diff --git a/webkit/glue/webthread_impl.cc b/webkit/glue/webthread_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c3904ba3312c645dfa43a2a67acf01126eb66bd0
--- /dev/null
+++ b/webkit/glue/webthread_impl.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2011 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.
+
+// An implementation of WebThread in terms of base::MessageLoop and
+// base::Thread
+
+#include "webkit/glue/webthread_impl.h"
+
+#include "base/scoped_ptr.h"
+#include "base/task.h"
+#include "base/message_loop.h"
+
+namespace webkit_glue {
+
+class TaskAdapter : public Task {
+public:
+ TaskAdapter(WebKit::WebThread::Task* task) : task_(task) { }
+ virtual void Run() {
+ task_->run();
+ }
+private:
+ scoped_ptr<WebKit::WebThread::Task> task_;
+};
+
+WebThreadImpl::WebThreadImpl(const char* name)
+ : thread_(new base::Thread(name)) {
+ thread_->Start();
+}
+
+void WebThreadImpl::postTask(Task* task) {
+ thread_->message_loop()->PostTask(FROM_HERE,
+ new TaskAdapter(task));
+}
+void WebThreadImpl::postDelayedTask(
+ Task* task, int64 delay_ms) {
+ thread_->message_loop()->PostDelayedTask(
+ FROM_HERE, new TaskAdapter(task), delay_ms);
+}
+
+WebThreadImpl::~WebThreadImpl() {
+ thread_->Stop();
+}
+
+}
« no previous file with comments | « webkit/glue/webthread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698