summaryrefslogtreecommitdiff
path: root/chromium/pdf/timer.cc
blob: cbd11a0a38be6d3583e7933039599428f7aa5c96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "pdf/timer.h"

#include "ppapi/cpp/core.h"
#include "ppapi/cpp/module.h"

namespace chrome_pdf {

Timer::Timer(base::TimeDelta delay) : delay_(delay), callback_factory_(this) {
  PostCallback();
}

Timer::~Timer() = default;

void Timer::PostCallback() {
  pp::CompletionCallback callback =
      callback_factory_.NewCallback(&Timer::TimerProc);
  pp::Module::Get()->core()->CallOnMainThread(delay_.InMilliseconds(), callback,
                                              0);
}

void Timer::TimerProc(int32_t /*result*/) {
  PostCallback();
  OnTimer();
}

}  // namespace chrome_pdf