| 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.Send(reinterpret_cast<const char*>(&i), sizeof(int)); |
| 32 | Sleep(milliseconds); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | void HandleProgressCallback(const char *data, size_t count) { |
| 37 | HandleScope scope; |
| 38 | |
| 39 | v8::Local<v8::Value> argv[] = { |
| 40 | New<v8::Integer>(*reinterpret_cast<int*>(const_cast<char*>(data))) |
| 41 | }; |
| 42 | progress->Call(1, argv, async_resource); |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | Callback *progress; |
| 47 | int milliseconds; |
| 48 | int iters; |
| 49 | }; |
| 50 | |
| 51 | NAN_METHOD(DoProgress) { |
| 52 | Callback *progress = new Callback(To<v8::Function>(info[2]).ToLocalChecked()); |
nothing calls this directly
no outgoing calls
no test coverage detected