Chromium Code Reviews| Index: include/v8-platform.h |
| diff --git a/include/v8-defaults.h b/include/v8-platform.h |
| similarity index 52% |
| rename from include/v8-defaults.h |
| rename to include/v8-platform.h |
| index 381a48210d1b9895fbda4e4c89eb0e51fa61b6d0..75fddd59a873b75db0d05bd1e3fc733b1e1a9265 100644 |
| --- a/include/v8-defaults.h |
| +++ b/include/v8-platform.h |
| @@ -25,30 +25,62 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -#ifndef V8_V8_DEFAULTS_H_ |
| -#define V8_V8_DEFAULTS_H_ |
| +#ifndef V8_V8_PLATFORM_H_ |
| +#define V8_V8_PLATFORM_H_ |
| #include "v8.h" |
| -/** |
| - * Default configuration support for the V8 JavaScript engine. |
| - */ |
| namespace v8 { |
| /** |
| - * Configures the constraints with reasonable default values based on the |
| - * capabilities of the current device the VM is running on. |
| + * A Task represents a unit of work. |
| */ |
| -bool V8_EXPORT ConfigureResourceConstraintsForCurrentPlatform( |
|
Paweł Hajdan Jr.
2013/12/20 12:16:43
Looks like changes have been made here without dep
|
| - ResourceConstraints* constraints); |
| +class Task { |
| + public: |
| + virtual ~Task() {} |
| + virtual void Run() = 0; |
| +}; |
| /** |
| - * Convience function which performs SetResourceConstraints with the settings |
| - * returned by ConfigureResourceConstraintsForCurrentPlatform. |
| + * V8 Platform abstraction layer. |
| + * |
| + * The embedder has to provide an implementation of this interface before |
| + * initializing the rest of V8. |
| */ |
| -bool V8_EXPORT SetDefaultResourceConstraintsForCurrentPlatform(); |
| +class Platform { |
| + public: |
| + /** |
| + * This enum is used to indicate whether a task is potentially long running, |
| + * or causes a long wait. The embedder might want to use this hint to decide |
| + * whether to execute the task on a dedicated thread. |
| + */ |
| + enum ExpectedRuntime { |
| + kShortRunningTask, |
| + kLongRunningTask |
| + }; |
| + |
| + /** |
| + * Schedules a task to be invoked on a background thread. |expected_runtime| |
| + * indicates that the task will run a long time. The Platform implementation |
| + * takes ownership of |task|. There is no guarantee about order of execution |
| + * of tasks wrt order of scheduling, nor is there a guarantee about the |
| + * thread the task will be run on. |
| + */ |
| + virtual void CallOnBackgroundThread(Task* task, |
| + ExpectedRuntime expected_runtime) = 0; |
| + |
| + /** |
| + * Schedules a task to be invoked on a foreground thread wrt a specific |
| + * |isolate|. Tasks posted for the same isolate should be execute in order of |
| + * scheduling. The definition of "foreground" is opaque to V8. |
| + */ |
| + virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0; |
| + |
| + protected: |
| + virtual ~Platform() {} |
| +}; |
| } // namespace v8 |
| -#endif // V8_V8_DEFAULTS_H_ |
| +#endif // V8_V8_PLATFORM_H_ |