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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webkit/glue/worker_task_runner.h
diff --git a/webkit/glue/worker_task_runner.h b/webkit/glue/worker_task_runner.h
new file mode 100644
index 0000000000000000000000000000000000000000..3c8ed3dd3fe80350dec020c6c71c8fbd2993d124
--- /dev/null
+++ b/webkit/glue/worker_task_runner.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_WORKER_TASK_RUNNER_H_
+#define CONTENT_COMMON_WORKER_TASK_RUNNER_H_
+#pragma once
+
+#include <map>
+#include <set>
+
+#include "base/callback_forward.h"
+#include "base/synchronization/lock.h"
+#include "base/threading/thread_local.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerRunLoop.h"
+
+namespace webkit_glue {
+
+class WorkerTaskRunner {
+ public:
+ WorkerTaskRunner();
+
+ void PostTask(int id, const base::Closure& task);
+ int CurrentWorkerId();
+ static WorkerTaskRunner* Instance();
+
+ class Observer {
+ public:
+ virtual ~Observer() {}
+ virtual void OnWorkerRunLoopStarted() {}
+ virtual void OnWorkerRunLoopStopped() {}
+ };
+ // Can be called on any thread. The notifications will be called on the
+ // worker thread in question.
+ void AddObserver(Observer* observer);
+ // Returns 1 if a matching observer was found and removed, 0 otherwise.
+ int RemoveObserver(Observer* observer);
+
+ private:
+ friend class WebKitPlatformSupportImpl;
+ friend class WorkerTaskRunnerTest;
+
+ typedef std::map<int, WebKit::WebWorkerRunLoop> IDToLoopMap;
+
+ ~WorkerTaskRunner();
+ void OnWorkerRunLoopStarted(const WebKit::WebWorkerRunLoop& loop);
+ void OnWorkerRunLoopStopped(const WebKit::WebWorkerRunLoop& loop);
+
+ base::ThreadLocalPointer<std::pair<int, WebKit::WebWorkerRunLoop> >
+ current_tls_;
+
+ base::Lock lock_;
+ int id_sequence_;
+ IDToLoopMap loop_map_;
+
+ typedef std::set<Observer*> ObserverList;
+ ObserverList observer_list_;
+ base::Lock observer_lock_;
+};
+
+} // namespace webkit_glue
+
+#endif // CONTENT_COMMON_SOCKET_STREAM_H_

Powered by Google App Engine
This is Rietveld 408576698