| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/client_side_model_loader.h" | 5 #include "chrome/browser/safe_browsing/client_side_model_loader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // We're adding 60s of additional delay to make sure we're past | 180 // We're adding 60s of additional delay to make sure we're past |
| 181 // the model's age. | 181 // the model's age. |
| 182 max_age += base::TimeDelta::FromMinutes(1); | 182 max_age += base::TimeDelta::FromMinutes(1); |
| 183 delay_ms = max_age.InMilliseconds(); | 183 delay_ms = max_age.InMilliseconds(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Schedule the next model reload. | 186 // Schedule the next model reload. |
| 187 ScheduleFetch(delay_ms); | 187 ScheduleFetch(delay_ms); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ModelLoader::ScheduleFetch(int64 delay_ms) { | 190 void ModelLoader::ScheduleFetch(int64_t delay_ms) { |
| 191 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 191 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 192 switches::kSbDisableAutoUpdate)) | 192 switches::kSbDisableAutoUpdate)) |
| 193 return; | 193 return; |
| 194 base::MessageLoop::current()->PostDelayedTask( | 194 base::MessageLoop::current()->PostDelayedTask( |
| 195 FROM_HERE, | 195 FROM_HERE, |
| 196 base::Bind(&ModelLoader::StartFetch, weak_factory_.GetWeakPtr()), | 196 base::Bind(&ModelLoader::StartFetch, weak_factory_.GetWeakPtr()), |
| 197 base::TimeDelta::FromMilliseconds(delay_ms)); | 197 base::TimeDelta::FromMilliseconds(delay_ms)); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void ModelLoader::CancelFetcher() { | 200 void ModelLoader::CancelFetcher() { |
| 201 // Invalidate any scheduled request. | 201 // Invalidate any scheduled request. |
| 202 weak_factory_.InvalidateWeakPtrs(); | 202 weak_factory_.InvalidateWeakPtrs(); |
| 203 // Cancel any request in progress. | 203 // Cancel any request in progress. |
| 204 fetcher_.reset(); | 204 fetcher_.reset(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace safe_browsing | 207 } // namespace safe_browsing |
| OLD | NEW |