Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Unified Diff: pdf/timer.cc

Issue 2455403002: Reland of Improve linearized pdf load/show time. (Closed)
Patch Set: Fix review issues Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/timer.h ('k') | pdf/url_loader_wrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/timer.cc
diff --git a/pdf/timer.cc b/pdf/timer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a6890b245bf740d68a76a8464bf51309f49d9cc3
--- /dev/null
+++ b/pdf/timer.cc
@@ -0,0 +1,31 @@
+// 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(int delay_in_milliseconds)
+ : delay_(delay_in_milliseconds), callback_factory_(this) {
+ PostCallback();
+}
+
+Timer::~Timer() {
+}
+
+void Timer::PostCallback() {
+ pp::CompletionCallback callback =
+ callback_factory_.NewCallback(&Timer::TimerProc);
+ pp::Module::Get()->core()->CallOnMainThread(delay_, callback, 0);
+}
+
+void Timer::TimerProc(int32_t /*result*/) {
+ PostCallback();
+ OnTimer();
+}
+
+} // namespace chrome_pdf
« no previous file with comments | « pdf/timer.h ('k') | pdf/url_loader_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698