Hide Google logo and custom launcher page in app list for non-Google search engines.
[chromium-blink-merge.git] / content / child / webthread_impl.h
blobba2888f9bc70b007789d3f8ce022234ec45c3f33
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 blink {
16 class WebTraceLocation;
19 namespace content {
21 class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
22 public:
23 virtual ~WebThreadBase();
25 virtual void addTaskObserver(TaskObserver* observer);
26 virtual void removeTaskObserver(TaskObserver* observer);
28 virtual bool isCurrentThread() const = 0;
29 virtual blink::PlatformThreadId threadId() const = 0;
31 protected:
32 WebThreadBase();
34 private:
35 class TaskObserverAdapter;
37 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
38 TaskObserverMap task_observer_map_;
41 class CONTENT_EXPORT WebThreadImpl : public WebThreadBase {
42 public:
43 explicit WebThreadImpl(const char* name);
44 virtual ~WebThreadImpl();
46 virtual void postTask(const blink::WebTraceLocation& location, Task* task);
47 virtual void postDelayedTask(const blink::WebTraceLocation& location,
48 Task* task,
49 long long delay_ms);
51 // TODO(skyostil): Remove once blink has migrated.
52 virtual void postTask(Task* task);
53 virtual void postDelayedTask(Task* task, long long delay_ms);
55 virtual void enterRunLoop();
56 virtual void exitRunLoop();
58 base::MessageLoop* message_loop() const { return thread_->message_loop(); }
60 virtual bool isCurrentThread() const override;
61 virtual blink::PlatformThreadId threadId() const override;
63 private:
64 scoped_ptr<base::Thread> thread_;
67 class WebThreadImplForMessageLoop : public WebThreadBase {
68 public:
69 CONTENT_EXPORT explicit WebThreadImplForMessageLoop(
70 scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner);
71 CONTENT_EXPORT virtual ~WebThreadImplForMessageLoop();
73 virtual void postTask(const blink::WebTraceLocation& location, Task* task);
74 virtual void postDelayedTask(const blink::WebTraceLocation& location,
75 Task* task,
76 long long delay_ms);
78 // TODO(skyostil): Remove once blink has migrated.
79 virtual void postTask(Task* task);
80 virtual void postDelayedTask(Task* task, long long delay_ms);
82 virtual void enterRunLoop() override;
83 virtual void exitRunLoop() override;
85 private:
86 virtual bool isCurrentThread() const override;
87 virtual blink::PlatformThreadId threadId() const override;
89 scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner_;
90 blink::PlatformThreadId thread_id_;
93 } // namespace content
95 #endif // CONTENT_CHILD_WEBTHREAD_IMPL_H_