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 #include "components/rappor/log_uploader.h" | 5 #include "components/rappor/log_uploader.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "net/url_request/test_url_fetcher_factory.h" | 9 #include "net/url_request/test_url_fetcher_factory.h" |
10 #include "net/url_request/url_request_test_util.h" | 10 #include "net/url_request/url_request_test_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 void StartUpload() { | 28 void StartUpload() { |
29 last_interval_set_ = base::TimeDelta(); | 29 last_interval_set_ = base::TimeDelta(); |
30 StartScheduledUpload(); | 30 StartScheduledUpload(); |
31 } | 31 } |
32 | 32 |
33 static base::TimeDelta BackOff(base::TimeDelta t) { | 33 static base::TimeDelta BackOff(base::TimeDelta t) { |
34 return LogUploader::BackOffUploadInterval(t); | 34 return LogUploader::BackOffUploadInterval(t); |
35 } | 35 } |
36 | 36 |
37 protected: | 37 protected: |
38 virtual bool IsUploadScheduled() const OVERRIDE { | 38 virtual bool IsUploadScheduled() const override { |
39 return last_interval_set() != base::TimeDelta(); | 39 return last_interval_set() != base::TimeDelta(); |
40 } | 40 } |
41 | 41 |
42 // Schedules a future call to StartScheduledUpload if one isn't already | 42 // Schedules a future call to StartScheduledUpload if one isn't already |
43 // pending. | 43 // pending. |
44 virtual void ScheduleNextUpload(base::TimeDelta interval) OVERRIDE { | 44 virtual void ScheduleNextUpload(base::TimeDelta interval) override { |
45 EXPECT_EQ(last_interval_set(), base::TimeDelta()); | 45 EXPECT_EQ(last_interval_set(), base::TimeDelta()); |
46 last_interval_set_ = interval; | 46 last_interval_set_ = interval; |
47 } | 47 } |
48 | 48 |
49 base::TimeDelta last_interval_set_; | 49 base::TimeDelta last_interval_set_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(TestLogUploader); | 51 DISALLOW_COPY_AND_ASSIGN(TestLogUploader); |
52 }; | 52 }; |
53 | 53 |
54 } // namespace | 54 } // namespace |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Backoff until the maximum is reached. | 145 // Backoff until the maximum is reached. |
146 while (next > current) { | 146 while (next > current) { |
147 current = next; | 147 current = next; |
148 next = TestLogUploader::BackOff(current); | 148 next = TestLogUploader::BackOff(current); |
149 } | 149 } |
150 // Maximum backoff should have been reached. | 150 // Maximum backoff should have been reached. |
151 EXPECT_EQ(next, current); | 151 EXPECT_EQ(next, current); |
152 } | 152 } |
153 | 153 |
154 } // namespace rappor | 154 } // namespace rappor |
OLD | NEW |