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

Side by Side Diff: webkit/glue/webthread_impl.h

Issue 8805027: Implement WebThread::{add,remove}TaskObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/glue/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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef WEBKIT_GLUE_WEBTHREAD_IMPL_H_ 4 #ifndef WEBKIT_GLUE_WEBTHREAD_IMPL_H_
5 #define WEBKIT_GLUE_WEBTHREAD_IMPL_H_ 5 #define WEBKIT_GLUE_WEBTHREAD_IMPL_H_
6 6
7 #include <map>
8
7 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebThread.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebThread.h"
10 #include "webkit/glue/webkit_glue_export.h" 12 #include "webkit/glue/webkit_glue_export.h"
11 13
12 namespace webkit_glue { 14 namespace webkit_glue {
13 15
14 class WebThreadImpl : public WebKit::WebThread { 16 class WebThreadBase : public WebKit::WebThread {
15 public: 17 public:
16 WEBKIT_GLUE_EXPORT WebThreadImpl(const char* name); 18 virtual ~WebThreadBase();
19
20 virtual void addTaskObserver(TaskObserver* observer);
21 virtual void removeTaskObserver(TaskObserver* observer);
22
23 protected:
24 WebThreadBase();
25
26 private:
27 class TaskObserverAdapter;
28
29 virtual bool IsCurrentThread() const = 0;
30
31 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
32 TaskObserverMap task_observer_map_;
33 };
34
35 class WebThreadImpl : public WebThreadBase {
36 public:
37 WEBKIT_GLUE_EXPORT explicit WebThreadImpl(const char* name);
17 WEBKIT_GLUE_EXPORT virtual ~WebThreadImpl(); 38 WEBKIT_GLUE_EXPORT virtual ~WebThreadImpl();
18 39
19 virtual void postTask(Task* task) OVERRIDE; 40 virtual void postTask(Task* task) OVERRIDE;
20 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; 41 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE;
21 42
22 MessageLoop* message_loop() const { return thread_->message_loop(); } 43 MessageLoop* message_loop() const { return thread_->message_loop(); }
23 44
24 protected: 45 private:
46 virtual bool IsCurrentThread() const OVERRIDE;
25 scoped_ptr<base::Thread> thread_; 47 scoped_ptr<base::Thread> thread_;
26 }; 48 };
27 49
28 class WebThreadImplForMessageLoop : public WebKit::WebThread { 50 class WebThreadImplForMessageLoop : public WebThreadBase {
29 public: 51 public:
30 WebThreadImplForMessageLoop(base::MessageLoopProxy* message_loop); 52 explicit WebThreadImplForMessageLoop(base::MessageLoopProxy* message_loop);
31 virtual ~WebThreadImplForMessageLoop(); 53 virtual ~WebThreadImplForMessageLoop();
32 54
33 virtual void postTask(Task* task) OVERRIDE; 55 virtual void postTask(Task* task) OVERRIDE;
34 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; 56 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE;
35 57
36 protected: 58 private:
59 virtual bool IsCurrentThread() const OVERRIDE;
37 scoped_refptr<base::MessageLoopProxy> message_loop_; 60 scoped_refptr<base::MessageLoopProxy> message_loop_;
38 }; 61 };
39 62
40 } // namespace webkit_glue 63 } // namespace webkit_glue
41 64
42 #endif 65 #endif
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/webthread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698