| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/safe_browsing_db/v4_update_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_update_protocol_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // According to section 5 of the SafeBrowsing protocol specification, we must | 152 // According to section 5 of the SafeBrowsing protocol specification, we must |
| 153 // back off after a certain number of errors. | 153 // back off after a certain number of errors. |
| 154 base::TimeDelta V4UpdateProtocolManager::GetNextUpdateInterval(bool back_off) { | 154 base::TimeDelta V4UpdateProtocolManager::GetNextUpdateInterval(bool back_off) { |
| 155 DCHECK(CalledOnValidThread()); | 155 DCHECK(CalledOnValidThread()); |
| 156 DCHECK(next_update_interval_ > base::TimeDelta()); | 156 DCHECK(next_update_interval_ > base::TimeDelta()); |
| 157 base::TimeDelta next = next_update_interval_; | 157 base::TimeDelta next = next_update_interval_; |
| 158 if (back_off) { | 158 if (back_off) { |
| 159 next = V4ProtocolManagerUtil::GetNextBackOffInterval( | 159 next = V4ProtocolManagerUtil::GetNextBackOffInterval( |
| 160 &update_error_count_, &update_back_off_mult_); | 160 &update_error_count_, &update_back_off_mult_); |
| 161 } | 161 } |
| 162 DVLOG(1) << "V4UpdateProtocolManager::GetNextUpdateInterval: " |
| 163 << "next_interval: " << next; |
| 162 return next; | 164 return next; |
| 163 } | 165 } |
| 164 | 166 |
| 165 void V4UpdateProtocolManager::ScheduleNextUpdateAfterInterval( | 167 void V4UpdateProtocolManager::ScheduleNextUpdateAfterInterval( |
| 166 base::TimeDelta interval) { | 168 base::TimeDelta interval) { |
| 167 DCHECK(CalledOnValidThread()); | 169 DCHECK(CalledOnValidThread()); |
| 168 DCHECK(interval >= base::TimeDelta()); | 170 DCHECK(interval >= base::TimeDelta()); |
| 169 // Unschedule any current timer. | 171 // Unschedule any current timer. |
| 170 update_timer_.Stop(); | 172 update_timer_.Stop(); |
| 171 update_timer_.Start(FROM_HERE, interval, this, | 173 update_timer_.Start(FROM_HERE, interval, this, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 306 } |
| 305 // TODO(vakh): Figure out whether it is just a network error vs backoff vs | 307 // TODO(vakh): Figure out whether it is just a network error vs backoff vs |
| 306 // another condition and RecordUpdateResult more accurately. | 308 // another condition and RecordUpdateResult more accurately. |
| 307 } | 309 } |
| 308 request_.reset(); | 310 request_.reset(); |
| 309 ScheduleNextUpdate(back_off); | 311 ScheduleNextUpdate(back_off); |
| 310 } | 312 } |
| 311 | 313 |
| 312 GURL V4UpdateProtocolManager::GetUpdateUrl( | 314 GURL V4UpdateProtocolManager::GetUpdateUrl( |
| 313 const std::string& req_base64) const { | 315 const std::string& req_base64) const { |
| 314 return V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedUpdates", | 316 GURL url = V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedUpdates", |
| 315 config_); | 317 config_); |
| 318 DVLOG(1) << "V4UpdateProtocolManager::GetUpdateUrl: " |
| 319 << "url: " << url; |
| 320 return url; |
| 316 } | 321 } |
| 317 | 322 |
| 318 } // namespace safe_browsing | 323 } // namespace safe_browsing |
| OLD | NEW |