OLD | NEW |
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 #ifndef COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ | 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ |
6 #define COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ | 6 #define COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "components/domain_reliability/monitor.h" | 9 #include "components/domain_reliability/monitor.h" |
10 #include "components/domain_reliability/uploader.h" | 10 #include "components/domain_reliability/uploader.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 }; | 36 }; |
37 | 37 |
38 class MockUploader : public DomainReliabilityUploader { | 38 class MockUploader : public DomainReliabilityUploader { |
39 public: | 39 public: |
40 typedef base::Callback<void(const std::string& report_json, | 40 typedef base::Callback<void(const std::string& report_json, |
41 const GURL& upload_url, | 41 const GURL& upload_url, |
42 const UploadCallback& upload_callback)> | 42 const UploadCallback& upload_callback)> |
43 UploadRequestCallback; | 43 UploadRequestCallback; |
44 | 44 |
45 MockUploader(const UploadRequestCallback& callback); | 45 MockUploader(const UploadRequestCallback& callback); |
| 46 |
46 virtual ~MockUploader(); | 47 virtual ~MockUploader(); |
47 | 48 |
48 // DomainReliabilityUploader implementation: | 49 // DomainReliabilityUploader implementation: |
49 virtual void UploadReport(const std::string& report_json, | 50 virtual void UploadReport(const std::string& report_json, |
50 const GURL& upload_url, | 51 const GURL& upload_url, |
51 const UploadCallback& callback) OVERRIDE; | 52 const UploadCallback& callback) OVERRIDE; |
52 | 53 |
53 private: | 54 private: |
54 UploadRequestCallback callback_; | 55 UploadRequestCallback callback_; |
55 }; | 56 }; |
56 | 57 |
57 class MockTime : public MockableTime { | 58 class MockTime : public MockableTime { |
58 public: | 59 public: |
59 MockTime(); | 60 MockTime(); |
| 61 |
60 // N.B.: Tasks (and therefore Timers) scheduled to run in the future will | 62 // N.B.: Tasks (and therefore Timers) scheduled to run in the future will |
61 // never be run if MockTime is destroyed before the mock time is advanced | 63 // never be run if MockTime is destroyed before the mock time is advanced |
62 // to their scheduled time. | 64 // to their scheduled time. |
63 virtual ~MockTime(); | 65 virtual ~MockTime(); |
64 | 66 |
65 // MockableTime implementation: | 67 // MockableTime implementation: |
66 virtual base::Time Now() OVERRIDE; | 68 virtual base::Time Now() OVERRIDE; |
67 virtual base::TimeTicks NowTicks() OVERRIDE; | 69 virtual base::TimeTicks NowTicks() OVERRIDE; |
68 virtual scoped_ptr<MockableTime::Timer> CreateTimer() OVERRIDE; | 70 virtual scoped_ptr<MockableTime::Timer> CreateTimer() OVERRIDE; |
69 | 71 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::Time now_; | 108 base::Time now_; |
107 base::TimeTicks now_ticks_; | 109 base::TimeTicks now_ticks_; |
108 base::TimeTicks epoch_ticks_; | 110 base::TimeTicks epoch_ticks_; |
109 int task_sequence_number_; | 111 int task_sequence_number_; |
110 TaskMap tasks_; | 112 TaskMap tasks_; |
111 }; | 113 }; |
112 | 114 |
113 } // namespace domain_reliability | 115 } // namespace domain_reliability |
114 | 116 |
115 #endif // COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ | 117 #endif // COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ |
OLD | NEW |