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

Unified 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: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: net/test/fake_time_system.h
diff --git a/net/test/fake_time_system.h b/net/test/fake_time_system.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a3997308b74f6630fb7510179ef9cdc8fe02b56
--- /dev/null
+++ b/net/test/fake_time_system.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2013 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.
+
+#ifndef NET_TEST_FAKE_TIME_SYSTEM_H_
+#define NET_TEST_FAKE_TIME_SYSTEM_H_
+
+#include <queue>
+
+#include "base/callback.h"
+#include "base/task_runner.h"
+#include "base/time/clock.h"
+
+namespace net {
+
+class FakeTimeSystem : public base::Clock, public base::TaskRunner {
szym 2013/05/24 15:32:22 Needs class-level comment. Not sure you need this.
Noam Samuel 2013/05/29 21:25:16 Done.
+ public:
+ class Task {
+ public:
+ Task(base::Time time, base::Closure task);
+ ~Task();
+
+ bool operator<(const Task &other) const;
+
+ const base::Closure& closure() const { return task_; }
+ const base::Time time() const { return time_; }
+
+ private:
+ base::Closure task_;
+ base::Time time_;
+ };
+
+
+ FakeTimeSystem();
+
+ void SetNow(base::Time now);
+
+ // Runs pending tasks until the queue is empty. Runs only tasks
+ // that are supposed to be run after |now_|.
+ void RunPendingTasks();
+
+ virtual base::Time Now() OVERRIDE;
+
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) OVERRIDE;
+
+ virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
+
+ private:
+ virtual ~FakeTimeSystem();
+
+ base::Time now_;
+ std::priority_queue<Task> tasks_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeTimeSystem);
+};
+}
+
+#endif // NET_TEST_FAKE_TIME_SYSTEM_H_
« net/dns/mdns_query.h ('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