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

Side by Side Diff: webkit/glue/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: add WEBKIT_GLUE_EXPORT 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 | « webkit/glue/webkitplatformsupport_impl.cc ('k') | webkit/glue/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 WEBKIT_GLUE_WORKER_TASK_RUNNER_H_
6 #define WEBKIT_GLUE_WORKER_TASK_RUNNER_H_
7 #pragma once
8
9 #include <map>
10
11 #include "base/atomic_sequence_num.h"
12 #include "base/callback_forward.h"
13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread_local.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerRunLoop.h"
16 #include "webkit/glue/webkit_glue_export.h"
17
18 namespace webkit_glue {
19
20 class WEBKIT_GLUE_EXPORT WorkerTaskRunner {
21 public:
22 WorkerTaskRunner();
23
24 void PostTask(int id, const base::Closure& task);
25 int CurrentWorkerId();
26 static WorkerTaskRunner* Instance();
27
28 class Observer {
29 public:
30 virtual ~Observer() {}
31 virtual void OnWorkerRunLoopStopped() = 0;
32 };
33 // Add/Remove an observer that will get notified when the current worker run
34 // loop is stopping. This observer will not get notified when other threads
35 // are stopping. It's only valid to call these on a worker thread.
36 void AddStopObserver(Observer* observer);
37 void RemoveStopObserver(Observer* observer);
38
39 private:
40 friend class WebKitPlatformSupportImpl;
41 friend class WorkerTaskRunnerTest;
42
43 typedef std::map<int, WebKit::WebWorkerRunLoop> IDToLoopMap;
44
45 ~WorkerTaskRunner();
46 void OnWorkerRunLoopStarted(const WebKit::WebWorkerRunLoop& loop);
47 void OnWorkerRunLoopStopped(const WebKit::WebWorkerRunLoop& loop);
48
49 struct ThreadLocalState;
50 base::ThreadLocalPointer<ThreadLocalState> current_tls_;
51
52 base::AtomicSequenceNumber id_sequence_;
53 IDToLoopMap loop_map_;
54 base::Lock loop_map_lock_;
55 };
56
57 } // namespace webkit_glue
58
59 #endif // WEBKIT_GLUE_WORKER_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « webkit/glue/webkitplatformsupport_impl.cc ('k') | webkit/glue/worker_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698