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

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: add static accessor to WorkerTaskRunner, use custom ObserverList 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 "base/callback_forward.h"
10 #include "base/synchronization/lock.h"
11 #include "base/threading/thread_local.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerRunLoop.h"
13
14 #include <map>
darin (slow to review) 2011/12/08 22:41:21 nit: these are supposed to go above the other incl
dgrogan 2011/12/09 03:20:41 Done.
15 #include <set>
16
17 class WorkerTaskRunner {
18 public:
19 WorkerTaskRunner();
20
21 void PostTask(int id, const base::Closure& task);
22 int CurrentWorkerId();
23 static WorkerTaskRunner* Instance();
24
25 class Observer {
26 public:
27 virtual ~Observer() {}
28 virtual void OnWorkerRunLoopStarted();
29 virtual void OnWorkerRunLoopStopped();
michaeln 2011/12/09 00:43:32 pure virtual?
dgrogan 2011/12/09 03:20:41 I gave them a default empty implementation.
30 };
31 // Can be called on any thread. The notifications will be called on the
32 // worker thread in question.
33 void AddObserver(Observer* obs);
34 // Unlike most Observerlists, observers can't remove themselves from this one
35 // during a notification. Deadlock may result.
36 // Returns number of observers removed.
michaeln 2011/12/08 03:10:47 why the return value?
dgrogan 2011/12/09 03:20:41 Mostly because it's available and could feasibly b
37 int RemoveObserver(Observer* obs);
38
39 private:
40 friend class RendererWebKitPlatformSupportImpl;
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 base::ThreadLocalPointer<std::pair<int, WebKit::WebWorkerRunLoop> >
49 current_tls_;
50
51 base::Lock lock_;
52 int id_sequence_;
53 IDToLoopMap loop_map_;
54
55 typedef std::set<Observer*> ObserverList;
56 ObserverList observer_list_;
57 base::Lock observer_lock_;
58 };
59
60 #endif // CONTENT_COMMON_SOCKET_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/worker_task_runner.cc » ('j') | content/common/worker_task_runner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698