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

Side by Side Diff: cc/output/report_time_swap_promise.cc

Issue 2835763002: Use swap-promise to improve first* paint times (Closed)
Patch Set: remove printfs Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium 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 "cc/output/report_time_swap_promise.h"
6 #include "base/bind.h"
7 #include "base/single_thread_task_runner.h"
8
9 namespace cc {
10
11 namespace {
12 double MonotonicallyIncreasingTime() {
13 return base::TimeTicks::Now().ToInternalValue() /
14 static_cast<double>(base::Time::kMicrosecondsPerSecond);
15 }
16 }
17
18 ReportTimeSwapPromise::ReportTimeSwapPromise(
19 ReportTimeCallback callback,
20 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
21 : callback_(callback), task_runner_(task_runner) {}
22
23 ReportTimeSwapPromise::~ReportTimeSwapPromise() {}
24
25 void ReportTimeSwapPromise::DidSwap() {
26 task_runner_->PostTask(
27 FROM_HERE,
28 base::BindOnce(callback_, true, MonotonicallyIncreasingTime()));
29 }
30
31 SwapPromise::DidNotSwapAction ReportTimeSwapPromise::DidNotSwap(
32 SwapPromise::DidNotSwapReason reason) {
33 task_runner_->PostTask(FROM_HERE, base::BindOnce(callback_, false, 0));
34 return SwapPromise::DidNotSwapAction::BREAK_PROMISE;
35 }
36
37 int64_t ReportTimeSwapPromise::TraceId() const {
38 return 0;
39 }
40
41 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698