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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webthread_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 // An implementation of WebThread in terms of base::MessageLoop and
6 // base::Thread
7
8 #include "webkit/glue/webthread_impl.h"
9
10 #include "base/scoped_ptr.h"
11 #include "base/task.h"
12 #include "base/message_loop.h"
13
14 namespace webkit_glue {
15
16 class TaskAdapter : public Task {
17 public:
18 TaskAdapter(WebKit::WebThread::Task* task) : task_(task) { }
19 virtual void Run() {
20 task_->run();
21 }
22 private:
23 scoped_ptr<WebKit::WebThread::Task> task_;
24 };
25
26 WebThreadImpl::WebThreadImpl(const char* name)
27 : thread_(new base::Thread(name)) {
28 thread_->Start();
29 }
30
31 void WebThreadImpl::postTask(Task* task) {
32 thread_->message_loop()->PostTask(FROM_HERE,
33 new TaskAdapter(task));
34 }
35 void WebThreadImpl::postDelayedTask(
36 Task* task, int64 delay_ms) {
37 thread_->message_loop()->PostDelayedTask(
38 FROM_HERE, new TaskAdapter(task), delay_ms);
39 }
40
41 WebThreadImpl::~WebThreadImpl() {
42 thread_->Stop();
43 }
44
45 }
OLDNEW
« 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