LCOV - code coverage report
Current view: top level - src - task-utils.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 17 21 81.0 %
Date: 2019-04-17 Functions: 12 14 85.7 %

          Line data    Source code
       1             : // Copyright 2018 the V8 project 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             : #include "src/task-utils.h"
       6             : 
       7             : #include "src/cancelable-task.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : 
      12             : namespace {
      13             : 
      14      271495 : class CancelableFuncTask final : public CancelableTask {
      15             :  public:
      16       90441 :   CancelableFuncTask(Isolate* isolate, std::function<void()> func)
      17      180882 :       : CancelableTask(isolate), func_(std::move(func)) {}
      18          58 :   CancelableFuncTask(CancelableTaskManager* manager, std::function<void()> func)
      19         116 :       : CancelableTask(manager), func_(std::move(func)) {}
      20      178999 :   void RunInternal() final { func_(); }
      21             : 
      22             :  private:
      23             :   const std::function<void()> func_;
      24             : };
      25             : 
      26          48 : class CancelableIdleFuncTask final : public CancelableIdleTask {
      27             :  public:
      28           0 :   CancelableIdleFuncTask(Isolate* isolate, std::function<void(double)> func)
      29           0 :       : CancelableIdleTask(isolate), func_(std::move(func)) {}
      30          16 :   CancelableIdleFuncTask(CancelableTaskManager* manager,
      31             :                          std::function<void(double)> func)
      32          32 :       : CancelableIdleTask(manager), func_(std::move(func)) {}
      33          16 :   void RunInternal(double deadline_in_seconds) final {
      34             :     func_(deadline_in_seconds);
      35          16 :   }
      36             : 
      37             :  private:
      38             :   const std::function<void(double)> func_;
      39             : };
      40             : 
      41             : }  // namespace
      42             : 
      43       90441 : std::unique_ptr<CancelableTask> MakeCancelableTask(Isolate* isolate,
      44             :                                                    std::function<void()> func) {
      45      180882 :   return base::make_unique<CancelableFuncTask>(isolate, std::move(func));
      46             : }
      47             : 
      48          58 : std::unique_ptr<CancelableTask> MakeCancelableTask(
      49             :     CancelableTaskManager* manager, std::function<void()> func) {
      50         116 :   return base::make_unique<CancelableFuncTask>(manager, std::move(func));
      51             : }
      52             : 
      53           0 : std::unique_ptr<CancelableIdleTask> MakeCancelableIdleTask(
      54             :     Isolate* isolate, std::function<void(double)> func) {
      55           0 :   return base::make_unique<CancelableIdleFuncTask>(isolate, std::move(func));
      56             : }
      57             : 
      58          16 : std::unique_ptr<CancelableIdleTask> MakeCancelableIdleTask(
      59             :     CancelableTaskManager* manager, std::function<void(double)> func) {
      60          32 :   return base::make_unique<CancelableIdleFuncTask>(manager, std::move(func));
      61             : }
      62             : 
      63             : }  // namespace internal
      64             : }  // namespace v8

Generated by: LCOV version 1.10