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

Side by Side Diff: sky/viewer/platform/webthread_impl.h

Issue 673033002: Remove WebThread (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « sky/viewer/platform/platform_impl.cc ('k') | sky/viewer/platform/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
(Empty)
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.
4
5 #ifndef SKY_VIEWER_PLATFORM_WEBTHREAD_IMPL_H_
6 #define SKY_VIEWER_PLATFORM_WEBTHREAD_IMPL_H_
7
8 #include <map>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h"
12 #include "sky/engine/public/platform/WebThread.h"
13
14 namespace sky {
15
16 class WebThreadBase : public blink::WebThread {
17 public:
18 virtual ~WebThreadBase();
19
20 virtual void addTaskObserver(TaskObserver* observer);
21 virtual void removeTaskObserver(TaskObserver* observer);
22
23 virtual bool isCurrentThread() const = 0;
24 virtual blink::PlatformThreadId threadId() const = 0;
25
26 protected:
27 WebThreadBase();
28
29 private:
30 class TaskObserverAdapter;
31 class SignalObserverAdapter;
32
33 struct Adaptors {
34 TaskObserverAdapter* task_adaptor = nullptr;
35 SignalObserverAdapter* signal_adaptor = nullptr;
36 };
37
38 typedef std::map<TaskObserver*, Adaptors> ObserverMap;
39 ObserverMap observer_map_;
40 };
41
42 class WebThreadImpl : public WebThreadBase {
43 public:
44 explicit WebThreadImpl(const char* name);
45 virtual ~WebThreadImpl();
46
47 virtual void postTask(Task* task);
48 virtual void postDelayedTask(Task* task, long long delay_ms);
49
50 virtual void enterRunLoop();
51 virtual void exitRunLoop();
52
53 base::MessageLoop* message_loop() const { return thread_->message_loop(); }
54
55 virtual bool isCurrentThread() const;
56 virtual blink::PlatformThreadId threadId() const;
57
58 private:
59 scoped_ptr<base::Thread> thread_;
60 };
61
62 class WebThreadImplForMessageLoop : public WebThreadBase {
63 public:
64 explicit WebThreadImplForMessageLoop(
65 base::MessageLoopProxy* message_loop);
66 virtual ~WebThreadImplForMessageLoop();
67
68 virtual void postTask(Task* task);
69 virtual void postDelayedTask(Task* task, long long delay_ms);
70
71 virtual void enterRunLoop();
72 virtual void exitRunLoop();
73
74 private:
75 virtual bool isCurrentThread() const;
76 virtual blink::PlatformThreadId threadId() const;
77
78 scoped_refptr<base::MessageLoopProxy> message_loop_;
79 blink::PlatformThreadId thread_id_;
80 };
81
82 } // namespace sky
83
84 #endif // SKY_VIEWER_PLATFORM_WEBTHREAD_IMPL_H_
OLDNEW
« no previous file with comments | « sky/viewer/platform/platform_impl.cc ('k') | sky/viewer/platform/webthread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698