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

Side by Side Diff: content/child/webthread_impl.h

Issue 930063002: Revert of scheduler: Implement task observers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « content/child/threaded_data_provider.cc ('k') | content/child/webthread_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_WEBTHREAD_IMPL_H_ 5 #ifndef CONTENT_CHILD_WEBTHREAD_IMPL_H_
6 #define CONTENT_CHILD_WEBTHREAD_IMPL_H_ 6 #define CONTENT_CHILD_WEBTHREAD_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "third_party/WebKit/public/platform/WebThread.h" 13 #include "third_party/WebKit/public/platform/WebThread.h"
14 14
15 namespace blink { 15 namespace blink {
16 class WebTraceLocation; 16 class WebTraceLocation;
17 } 17 }
18 18
19 namespace content { 19 namespace content {
20 20
21 class CONTENT_EXPORT WebThreadBase : public blink::WebThread { 21 class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
22 public: 22 public:
23 virtual ~WebThreadBase(); 23 virtual ~WebThreadBase();
24 24
25 // blink::WebThread implementation.
26 virtual bool isCurrentThread() const;
27 virtual blink::PlatformThreadId threadId() const = 0;
28
29 virtual void postTask(const blink::WebTraceLocation& location, Task* task);
30 virtual void postDelayedTask(const blink::WebTraceLocation& location,
31 Task* task,
32 long long delay_ms);
33
34 virtual void enterRunLoop();
35 virtual void exitRunLoop();
36
37 virtual void addTaskObserver(TaskObserver* observer); 25 virtual void addTaskObserver(TaskObserver* observer);
38 virtual void removeTaskObserver(TaskObserver* observer); 26 virtual void removeTaskObserver(TaskObserver* observer);
39 27
40 // Returns the base::Bind-compatible task runner for posting tasks to this 28 virtual bool isCurrentThread() const = 0;
41 // thread. Can be called from any thread. 29 virtual blink::PlatformThreadId threadId() const = 0;
42 virtual base::SingleThreadTaskRunner* TaskRunner() const = 0;
43 30
44 protected: 31 protected:
32 WebThreadBase();
33
34 private:
45 class TaskObserverAdapter; 35 class TaskObserverAdapter;
46 36
47 WebThreadBase();
48
49 // Returns the underlying MessageLoop for this thread. Only used for entering
50 // and exiting a nested run loop. Only called on the thread that the
51 // WebThread belongs to.
52 virtual base::MessageLoop* MessageLoop() const = 0;
53
54 virtual void AddTaskObserverInternal(
55 base::MessageLoop::TaskObserver* observer);
56 virtual void RemoveTaskObserverInternal(
57 base::MessageLoop::TaskObserver* observer);
58
59 static void RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task);
60
61 private:
62 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; 37 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
63 TaskObserverMap task_observer_map_; 38 TaskObserverMap task_observer_map_;
64 }; 39 };
65 40
66 class CONTENT_EXPORT WebThreadImpl : public WebThreadBase { 41 class CONTENT_EXPORT WebThreadImpl : public WebThreadBase {
67 public: 42 public:
68 explicit WebThreadImpl(const char* name); 43 explicit WebThreadImpl(const char* name);
69 virtual ~WebThreadImpl(); 44 virtual ~WebThreadImpl();
70 45
71 // blink::WebThread implementation. 46 virtual void postTask(const blink::WebTraceLocation& location, Task* task);
72 blink::PlatformThreadId threadId() const override; 47 virtual void postDelayedTask(const blink::WebTraceLocation& location,
48 Task* task,
49 long long delay_ms);
73 50
74 // WebThreadBase implementation. 51 // TODO(skyostil): Remove once blink has migrated.
75 base::SingleThreadTaskRunner* TaskRunner() const override; 52 virtual void postTask(Task* task);
53 virtual void postDelayedTask(Task* task, long long delay_ms);
54
55 virtual void enterRunLoop();
56 virtual void exitRunLoop();
57
58 base::MessageLoop* message_loop() const { return thread_->message_loop(); }
59
60 virtual bool isCurrentThread() const override;
61 virtual blink::PlatformThreadId threadId() const override;
76 62
77 private: 63 private:
78 base::MessageLoop* MessageLoop() const override;
79
80 scoped_ptr<base::Thread> thread_; 64 scoped_ptr<base::Thread> thread_;
81 }; 65 };
82 66
83 class WebThreadImplForMessageLoop : public WebThreadBase { 67 class WebThreadImplForMessageLoop : public WebThreadBase {
84 public: 68 public:
85 CONTENT_EXPORT explicit WebThreadImplForMessageLoop( 69 CONTENT_EXPORT explicit WebThreadImplForMessageLoop(
86 scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner); 70 scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner);
87 CONTENT_EXPORT virtual ~WebThreadImplForMessageLoop(); 71 CONTENT_EXPORT virtual ~WebThreadImplForMessageLoop();
88 72
89 // blink::WebThread implementation. 73 virtual void postTask(const blink::WebTraceLocation& location, Task* task);
90 blink::PlatformThreadId threadId() const override; 74 virtual void postDelayedTask(const blink::WebTraceLocation& location,
75 Task* task,
76 long long delay_ms);
91 77
92 // WebThreadBase implementation. 78 // TODO(skyostil): Remove once blink has migrated.
93 base::MessageLoop* MessageLoop() const override; 79 virtual void postTask(Task* task);
80 virtual void postDelayedTask(Task* task, long long delay_ms);
81
82 virtual void enterRunLoop() override;
83 virtual void exitRunLoop() override;
94 84
95 private: 85 private:
96 base::SingleThreadTaskRunner* TaskRunner() const override; 86 virtual bool isCurrentThread() const override;
87 virtual blink::PlatformThreadId threadId() const override;
97 88
98 scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner_; 89 scoped_refptr<base::SingleThreadTaskRunner> owning_thread_task_runner_;
99 blink::PlatformThreadId thread_id_; 90 blink::PlatformThreadId thread_id_;
100 }; 91 };
101 92
102 } // namespace content 93 } // namespace content
103 94
104 #endif // CONTENT_CHILD_WEBTHREAD_IMPL_H_ 95 #endif // CONTENT_CHILD_WEBTHREAD_IMPL_H_
OLDNEW
« no previous file with comments | « content/child/threaded_data_provider.cc ('k') | content/child/webthread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698