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

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: address comments 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
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
17 namespace webkit_glue {
18
19 class WorkerTaskRunner {
20 public:
21 WorkerTaskRunner();
22
23 void PostTask(int id, const base::Closure& task);
24 int CurrentWorkerId();
25 static WorkerTaskRunner* Instance();
26
27 class Observer {
28 public:
29 virtual ~Observer() {}
30 virtual void OnWorkerRunLoopStopped() = 0;
31 };
32 // Add/Remove an observer that will get notified when the current worker run
33 // loop is stopping. This observer will not get notified when other threads
34 // are stopping. It's only valid to call these on a worker thread.
35 void AddStopObserver(Observer* observer);
36 void RemoveStopObserver(Observer* observer);
37
38 private:
39 friend class WebKitPlatformSupportImpl;
40 friend class WorkerTaskRunnerTest;
41
42 typedef std::map<int, WebKit::WebWorkerRunLoop> IDToLoopMap;
43
44 ~WorkerTaskRunner();
45 void OnWorkerRunLoopStarted(const WebKit::WebWorkerRunLoop& loop);
46 void OnWorkerRunLoopStopped(const WebKit::WebWorkerRunLoop& loop);
47
48 struct ThreadLocalState;
49 base::ThreadLocalPointer<ThreadLocalState> current_tls_;
50
51 base::AtomicSequenceNumber id_sequence_;
52 IDToLoopMap loop_map_;
53 base::Lock loop_map_lock_;
54 };
55
56 } // namespace webkit_glue
57
58 #endif // WEBKIT_GLUE_WORKER_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698