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

Side by Side Diff: chromeos/tpm/tpm_token_info_getter_unittest.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // closer to what's actually happening in production. 53 // closer to what's actually happening in production.
54 // The delays used by TPMTokenGetter should be monotonically increasing, so 54 // The delays used by TPMTokenGetter should be monotonically increasing, so
55 // the fake task runner does not handle task reordering based on the delays. 55 // the fake task runner does not handle task reordering based on the delays.
56 class FakeTaskRunner : public base::TaskRunner { 56 class FakeTaskRunner : public base::TaskRunner {
57 public: 57 public:
58 // |delays|: Vector to which the dalays seen by the task runner are saved. 58 // |delays|: Vector to which the dalays seen by the task runner are saved.
59 explicit FakeTaskRunner(std::vector<int64_t>* delays) : delays_(delays) {} 59 explicit FakeTaskRunner(std::vector<int64_t>* delays) : delays_(delays) {}
60 60
61 // base::TaskRunner overrides: 61 // base::TaskRunner overrides:
62 bool PostDelayedTask(const tracked_objects::Location& from_here, 62 bool PostDelayedTask(const tracked_objects::Location& from_here,
63 const base::Closure& task, 63 base::OnceClosure task,
64 base::TimeDelta delay) override { 64 base::TimeDelta delay) override {
65 delays_->push_back(delay.InMilliseconds()); 65 delays_->push_back(delay.InMilliseconds());
66 base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, task); 66 base::ThreadTaskRunnerHandle::Get()->PostTask(from_here, std::move(task));
67 return true; 67 return true;
68 } 68 }
69 bool RunsTasksOnCurrentThread() const override { return true; } 69 bool RunsTasksOnCurrentThread() const override { return true; }
70 70
71 protected: 71 protected:
72 ~FakeTaskRunner() override {} 72 ~FakeTaskRunner() override {}
73 73
74 private: 74 private:
75 // The vector of delays. 75 // The vector of delays.
76 std::vector<int64_t>* delays_; 76 std::vector<int64_t>* delays_;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 EXPECT_EQ("2222", reported_info.pin); 513 EXPECT_EQ("2222", reported_info.pin);
514 EXPECT_EQ(1, reported_info.slot_id); 514 EXPECT_EQ(1, reported_info.slot_id);
515 515
516 const int64_t kExpectedDelays[] = {100}; 516 const int64_t kExpectedDelays[] = {100};
517 EXPECT_EQ(std::vector<int64_t>(kExpectedDelays, 517 EXPECT_EQ(std::vector<int64_t>(kExpectedDelays,
518 kExpectedDelays + arraysize(kExpectedDelays)), 518 kExpectedDelays + arraysize(kExpectedDelays)),
519 delays_); 519 delays_);
520 } 520 }
521 521
522 } // namespace 522 } // namespace
OLDNEW
« no previous file with comments | « chromeos/dbus/blocking_method_caller_unittest.cc ('k') | components/memory_pressure/memory_pressure_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698