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

Side by Side Diff: net/test/fake_time_system.h

Issue 15733008: Multicast DNS implementation (initial) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mdns_implementation2
Patch Set: Uploading to check comments against diff (next upload will have files renamed) Created 7 years, 6 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 (c) 2013 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 #ifndef NET_TEST_FAKE_TIME_SYSTEM_H_
6 #define NET_TEST_FAKE_TIME_SYSTEM_H_
7
8 #include <queue>
9
10 #include "base/callback.h"
11 #include "base/task_runner.h"
12 #include "base/time/clock.h"
13
14 namespace net {
15
16 class FakeTimeSystem : public base::Clock, public base::TaskRunner {
17 public:
18 class Task {
19 public:
20 Task(base::Time time, base::Closure task);
21 ~Task();
22
23 bool operator<(const Task &other) const;
24
25 const base::Closure& closure() const { return task_; }
26 const base::Time time() const { return time_; }
27
28 private:
29 base::Closure task_;
30 base::Time time_;
31 };
32
33 FakeTimeSystem();
34
35 void SetNow(base::Time now);
36
37 // Runs pending tasks until the queue is empty. Runs only tasks
38 // that are supposed to be run after |now_|.
39 void RunPendingTasks();
40
41 virtual base::Time Now() OVERRIDE;
42
43 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
44 const base::Closure& task,
45 base::TimeDelta delay) OVERRIDE;
46
47 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
48
49 private:
50 virtual ~FakeTimeSystem();
51
52 base::Time now_;
53 std::priority_queue<Task> tasks_;
54
55 DISALLOW_COPY_AND_ASSIGN(FakeTimeSystem);
56 };
57 }
58
59 #endif // NET_TEST_FAKE_TIME_SYSTEM_H_
OLDNEW
« net/dns/mdns_listener_impl.cc ('K') | « net/net.gyp ('k') | net/test/fake_time_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698