Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / mojo / services / html_viewer / webthread_impl.h
blob3d22d860eb848aa1f9afe354ecf1b8ce6fa72865
1 // Copyright 2014 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.
5 #ifndef MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_
6 #define MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_
8 #include <map>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h"
12 #include "third_party/WebKit/public/platform/WebThread.h"
14 namespace mojo {
16 class WebThreadBase : public blink::WebThread {
17 public:
18 virtual ~WebThreadBase();
20 virtual void addTaskObserver(TaskObserver* observer);
21 virtual void removeTaskObserver(TaskObserver* observer);
23 virtual bool isCurrentThread() const = 0;
25 protected:
26 WebThreadBase();
28 private:
29 class TaskObserverAdapter;
31 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
32 TaskObserverMap task_observer_map_;
35 class WebThreadImpl : public WebThreadBase {
36 public:
37 explicit WebThreadImpl(const char* name);
38 virtual ~WebThreadImpl();
40 virtual void postTask(Task* task);
41 virtual void postDelayedTask(Task* task, long long delay_ms);
43 virtual void enterRunLoop();
44 virtual void exitRunLoop();
46 base::MessageLoop* message_loop() const { return thread_->message_loop(); }
48 virtual bool isCurrentThread() const;
50 private:
51 scoped_ptr<base::Thread> thread_;
54 class WebThreadImplForMessageLoop : public WebThreadBase {
55 public:
56 explicit WebThreadImplForMessageLoop(
57 base::MessageLoopProxy* message_loop);
58 virtual ~WebThreadImplForMessageLoop();
60 virtual void postTask(Task* task);
61 virtual void postDelayedTask(Task* task, long long delay_ms);
63 virtual void enterRunLoop();
64 virtual void exitRunLoop();
66 private:
67 virtual bool isCurrentThread() const;
68 scoped_refptr<base::MessageLoopProxy> message_loop_;
71 } // namespace mojo
73 #endif // MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_