| 13 | using namespace Nan; // NOLINT(build/namespaces) |
| 14 | |
| 15 | class ProgressWorker : public AsyncProgressWorker { |
| 16 | public: |
| 17 | ProgressWorker( |
| 18 | Callback *callback |
| 19 | , Callback *progress |
| 20 | , int milliseconds |
| 21 | , int iters) |
| 22 | : AsyncProgressWorker(callback), progress(progress) |
| 23 | , milliseconds(milliseconds), iters(iters) {} |
| 24 | |
| 25 | ~ProgressWorker() { |
| 26 | delete progress; |
| 27 | } |
| 28 | |
| 29 | void Execute (const AsyncProgressWorker::ExecutionProgress& progress) { |
| 30 | for (int i = 0; i < iters; ++i) { |
| 31 | progress.Signal(); |
| 32 | Sleep(milliseconds); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | void HandleProgressCallback(const char *data, size_t count) { |
| 37 | HandleScope scope; |
| 38 | |
| 39 | v8::Local<v8::Value> arg = New<v8::Boolean>(data == NULL && count == 0); |
| 40 | progress->Call(1, &arg, async_resource); |
| 41 | } |
| 42 | |
| 43 | private: |
| 44 | Callback *progress; |
| 45 | int milliseconds; |
| 46 | int iters; |
| 47 | }; |
| 48 | |
| 49 | NAN_METHOD(DoProgress) { |
| 50 | Callback *progress = new Callback(To<v8::Function>(info[2]).ToLocalChecked()); |
nothing calls this directly
no outgoing calls
no test coverage detected