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: public/platform/WebThread.h

Issue 1325073002: Introduce WebTaskRunner Patch 1/5 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix comment Created 5 years, 3 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 | « public/platform/WebTaskRunner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 16 matching lines...) Expand all
27 27
28 #include "WebCommon.h" 28 #include "WebCommon.h"
29 #include <stdint.h> 29 #include <stdint.h>
30 30
31 #ifdef INSIDE_BLINK 31 #ifdef INSIDE_BLINK
32 #include "wtf/Functional.h" 32 #include "wtf/Functional.h"
33 #endif 33 #endif
34 34
35 namespace blink { 35 namespace blink {
36 class WebScheduler; 36 class WebScheduler;
37 class WebTaskRunner;
37 class WebTraceLocation; 38 class WebTraceLocation;
38 39
39 // Always an integer value. 40 // Always an integer value.
40 typedef uintptr_t PlatformThreadId; 41 typedef uintptr_t PlatformThreadId;
41 42
42 // Provides an interface to an embedder-defined thread implementation. 43 // Provides an interface to an embedder-defined thread implementation.
43 // 44 //
44 // Deleting the thread blocks until all pending, non-delayed tasks have been 45 // Deleting the thread blocks until all pending, non-delayed tasks have been
45 // run. 46 // run.
46 class BLINK_PLATFORM_EXPORT WebThread { 47 class BLINK_PLATFORM_EXPORT WebThread {
(...skipping 15 matching lines...) Expand all
62 class BLINK_PLATFORM_EXPORT TaskObserver { 63 class BLINK_PLATFORM_EXPORT TaskObserver {
63 public: 64 public:
64 virtual ~TaskObserver() { } 65 virtual ~TaskObserver() { }
65 virtual void willProcessTask() = 0; 66 virtual void willProcessTask() = 0;
66 virtual void didProcessTask() = 0; 67 virtual void didProcessTask() = 0;
67 }; 68 };
68 69
69 // postTask() and postDelayedTask() take ownership of the passed Task 70 // postTask() and postDelayedTask() take ownership of the passed Task
70 // object. It is safe to invoke postTask() and postDelayedTask() from any 71 // object. It is safe to invoke postTask() and postDelayedTask() from any
71 // thread. 72 // thread.
73 // TODO(alexclarke): Remove postTask & postDelayedTask.
72 virtual void postTask(const WebTraceLocation&, Task*) = 0; 74 virtual void postTask(const WebTraceLocation&, Task*) = 0;
73 virtual void postDelayedTask(const WebTraceLocation&, Task*, long long delay Ms) = 0; 75 virtual void postDelayedTask(const WebTraceLocation&, Task*, long long delay Ms) = 0;
74 76
77 // Returns a WebTaskRunner bound to the underlying scheduler's default task queue.
78 virtual WebTaskRunner* taskRunner() { return nullptr; }
79
75 virtual bool isCurrentThread() const = 0; 80 virtual bool isCurrentThread() const = 0;
76 virtual PlatformThreadId threadId() const { return 0; } 81 virtual PlatformThreadId threadId() const { return 0; }
77 82
78 virtual void addTaskObserver(TaskObserver*) { } 83 virtual void addTaskObserver(TaskObserver*) { }
79 virtual void removeTaskObserver(TaskObserver*) { } 84 virtual void removeTaskObserver(TaskObserver*) { }
80 85
81 // Returns the scheduler associated with the thread. 86 // Returns the scheduler associated with the thread.
82 virtual WebScheduler* scheduler() const = 0; 87 virtual WebScheduler* scheduler() const = 0;
83 88
84 virtual ~WebThread() { } 89 virtual ~WebThread() { }
85 90
86 #ifdef INSIDE_BLINK 91 #ifdef INSIDE_BLINK
87 // Helpers for posting bound functions as tasks. 92 // Helpers for posting bound functions as tasks.
88 void postTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>); 93 void postTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>);
89 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>, long long delayMs); 94 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>, long long delayMs);
90 #endif 95 #endif
91 }; 96 };
92 97
93 } // namespace blink 98 } // namespace blink
94 99
95 #endif 100 #endif
OLDNEW
« no previous file with comments | « public/platform/WebTaskRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698