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

Side by Side Diff: content/common/worker_task_runner.h

Issue 8785013: Track webcore worker message loops in chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments after rebase Created 9 years 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 | « content/common/child_thread.cc ('k') | content/common/worker_task_runner.cc » ('j') | 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 #ifndef CONTENT_COMMON_WORKER_TASK_RUNNER_H_
6 #define CONTENT_COMMON_WORKER_TASK_RUNNER_H_
7 #pragma once
8
9 #include "base/callback_forward.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/observer_list.h"
12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread_local.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerRunLoop.h"
15
16 #include <map>
17
18
19 class WorkerTaskRunner : public base::RefCountedThreadSafe<WorkerTaskRunner> {
20 public:
21 WorkerTaskRunner();
22 ~WorkerTaskRunner();
23 // This could be changed to take a chromium closure that is then wrapped by
michaeln 2011/12/06 02:28:22 this comment is stale
24 // this class.
25 void PostTask(int id, const base::Closure& task);
26 int CurrentWorkerId();
27
28 class Observer {
29 public:
30 virtual ~Observer() {}
31 virtual void OnWorkerRunLoopStarted();
32 virtual void OnWorkerRunLoopStopped();
33 };
34 // Can be called on any thread. The notifications will be called on the
35 // worker thread in question.
36 void AddObserver(Observer* obs);
37 // Unlike most Observerlists, observers can't remove themselves from this one
38 // during a notification. Deadlock may result.
39 void RemoveObserver(Observer* obs);
40
41 private:
42 friend class RendererWebKitPlatformSupportImpl;
43
44 typedef std::map<int, WebKit::WebWorkerRunLoop> IDToLoopMap;
45
46 void OnWorkerRunLoopStarted(const WebKit::WebWorkerRunLoop& loop);
47 void OnWorkerRunLoopStopped(const WebKit::WebWorkerRunLoop& loop);
48
49 base::ThreadLocalPointer<std::pair<int, WebKit::WebWorkerRunLoop> >
50 current_tls_;
51
52 base::Lock lock_;
53 int id_sequence_;
54 IDToLoopMap loop_map_;
55
56 ObserverList<Observer> observer_list_;
57 base::Lock observer_lock_;
58 };
59
60 #endif // CONTENT_COMMON_SOCKET_STREAM_H_
OLDNEW
« no previous file with comments | « content/common/child_thread.cc ('k') | content/common/worker_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698