| 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_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "components/domain_reliability/config.h" | 10 #include "components/domain_reliability/config.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 MockUploader(const UploadRequestCallback& callback); | 47 MockUploader(const UploadRequestCallback& callback); |
| 48 | 48 |
| 49 virtual ~MockUploader(); | 49 virtual ~MockUploader(); |
| 50 | 50 |
| 51 virtual bool discard_uploads() const; | 51 virtual bool discard_uploads() const; |
| 52 | 52 |
| 53 // DomainReliabilityUploader implementation: | 53 // DomainReliabilityUploader implementation: |
| 54 virtual void UploadReport(const std::string& report_json, | 54 virtual void UploadReport(const std::string& report_json, |
| 55 const GURL& upload_url, | 55 const GURL& upload_url, |
| 56 const UploadCallback& callback) OVERRIDE; | 56 const UploadCallback& callback) override; |
| 57 | 57 |
| 58 virtual void set_discard_uploads(bool discard_uploads) OVERRIDE; | 58 virtual void set_discard_uploads(bool discard_uploads) override; |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 UploadRequestCallback callback_; | 61 UploadRequestCallback callback_; |
| 62 bool discard_uploads_; | 62 bool discard_uploads_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 class MockTime : public MockableTime { | 65 class MockTime : public MockableTime { |
| 66 public: | 66 public: |
| 67 MockTime(); | 67 MockTime(); |
| 68 | 68 |
| 69 // N.B.: Tasks (and therefore Timers) scheduled to run in the future will | 69 // N.B.: Tasks (and therefore Timers) scheduled to run in the future will |
| 70 // never be run if MockTime is destroyed before the mock time is advanced | 70 // never be run if MockTime is destroyed before the mock time is advanced |
| 71 // to their scheduled time. | 71 // to their scheduled time. |
| 72 virtual ~MockTime(); | 72 virtual ~MockTime(); |
| 73 | 73 |
| 74 // MockableTime implementation: | 74 // MockableTime implementation: |
| 75 virtual base::Time Now() OVERRIDE; | 75 virtual base::Time Now() override; |
| 76 virtual base::TimeTicks NowTicks() OVERRIDE; | 76 virtual base::TimeTicks NowTicks() override; |
| 77 virtual scoped_ptr<MockableTime::Timer> CreateTimer() OVERRIDE; | 77 virtual scoped_ptr<MockableTime::Timer> CreateTimer() override; |
| 78 | 78 |
| 79 // Pretends that |delta| has passed, and runs tasks that would've happened | 79 // Pretends that |delta| has passed, and runs tasks that would've happened |
| 80 // during that interval (with |Now()| returning proper values while they | 80 // during that interval (with |Now()| returning proper values while they |
| 81 // execute!) | 81 // execute!) |
| 82 void Advance(base::TimeDelta delta); | 82 void Advance(base::TimeDelta delta); |
| 83 | 83 |
| 84 // Queues |task| to be run after |delay|. (Lighter-weight than mocking an | 84 // Queues |task| to be run after |delay|. (Lighter-weight than mocking an |
| 85 // entire message pump.) | 85 // entire message pump.) |
| 86 void AddTask(base::TimeDelta delay, const base::Closure& task); | 86 void AddTask(base::TimeDelta delay, const base::Closure& task); |
| 87 | 87 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 scoped_ptr<const DomainReliabilityConfig> MakeTestConfig(); | 122 scoped_ptr<const DomainReliabilityConfig> MakeTestConfig(); |
| 123 scoped_ptr<const DomainReliabilityConfig> MakeTestConfigWithDomain( | 123 scoped_ptr<const DomainReliabilityConfig> MakeTestConfigWithDomain( |
| 124 const std::string& domain); | 124 const std::string& domain); |
| 125 DomainReliabilityScheduler::Params MakeTestSchedulerParams(); | 125 DomainReliabilityScheduler::Params MakeTestSchedulerParams(); |
| 126 | 126 |
| 127 } // namespace domain_reliability | 127 } // namespace domain_reliability |
| 128 | 128 |
| 129 #endif // COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ | 129 #endif // COMPONENTS_DOMAIN_RELIABILITY_TEST_UTIL_H_ |
| OLD | NEW |