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

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: remove debug code 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 CONTENT_COMMON_WORKER_TASK_RUNNER_H_
6 #define CONTENT_COMMON_WORKER_TASK_RUNNER_H_
7 #pragma once
8
9 #include <map>
10 #include <set>
11
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 OnWorkerRunLoopStarted() {}
31 virtual void OnWorkerRunLoopStopped() {}
32 };
33 // Can be called on any thread. The notifications will be called on the
34 // worker thread in question.
35 void AddObserver(Observer* observer);
36 // Returns 1 if a matching observer was found and removed, 0 otherwise.
37 int RemoveObserver(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 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 typedef std::set<Observer*> ObserverList;
57 ObserverList observer_list_;
58 base::Lock observer_lock_;
59 };
60
61 } // namespace webkit_glue
62
63 #endif // CONTENT_COMMON_SOCKET_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698