[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / child / webthread_impl.h
blob4c81b2579d6806fc2f2d601682ed2446a095a056
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 CONTENT_CHILD_WEBTHREAD_IMPL_H_
6 #define CONTENT_CHILD_WEBTHREAD_IMPL_H_
8 #include <map>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h"
12 #include "content/common/content_export.h"
13 #include "third_party/WebKit/public/platform/WebThread.h"
15 namespace content {
17 class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
18 public:
19 virtual ~WebThreadBase();
21 virtual void addTaskObserver(TaskObserver* observer);
22 virtual void removeTaskObserver(TaskObserver* observer);
24 virtual bool isCurrentThread() const = 0;
26 protected:
27 WebThreadBase();
29 private:
30 class TaskObserverAdapter;
32 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
33 TaskObserverMap task_observer_map_;
36 class CONTENT_EXPORT WebThreadImpl : public WebThreadBase {
37 public:
38 explicit WebThreadImpl(const char* name);
39 virtual ~WebThreadImpl();
41 virtual void postTask(Task* task);
42 virtual void postDelayedTask(Task* task, long long delay_ms);
44 virtual void enterRunLoop();
45 virtual void exitRunLoop();
47 base::MessageLoop* message_loop() const { return thread_->message_loop(); }
49 virtual bool isCurrentThread() const OVERRIDE;
51 private:
52 scoped_ptr<base::Thread> thread_;
55 class WebThreadImplForMessageLoop : public WebThreadBase {
56 public:
57 CONTENT_EXPORT explicit WebThreadImplForMessageLoop(
58 base::MessageLoopProxy* message_loop);
59 CONTENT_EXPORT virtual ~WebThreadImplForMessageLoop();
61 virtual void postTask(Task* task) OVERRIDE;
62 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE;
64 virtual void enterRunLoop() OVERRIDE;
65 virtual void exitRunLoop() OVERRIDE;
67 private:
68 virtual bool isCurrentThread() const OVERRIDE;
69 scoped_refptr<base::MessageLoopProxy> message_loop_;
72 } // namespace content
74 #endif // CONTENT_CHILD_WEBTHREAD_IMPL_H_