OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_detection_service.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_service.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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 !i.IsAtEnd(); i.Advance()) { | 238 !i.IsAtEnd(); i.Advance()) { |
239 SendModelToProcess(i.GetCurrentValue()); | 239 SendModelToProcess(i.GetCurrentValue()); |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { | 243 void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { |
244 MessageLoop::current()->PostDelayedTask( | 244 MessageLoop::current()->PostDelayedTask( |
245 FROM_HERE, | 245 FROM_HERE, |
246 base::Bind(&ClientSideDetectionService::StartFetchModel, | 246 base::Bind(&ClientSideDetectionService::StartFetchModel, |
247 weak_factory_.GetWeakPtr()), | 247 weak_factory_.GetWeakPtr()), |
248 delay_ms); | 248 base::TimeDelta::FromMilliseconds(delay_ms)); |
249 } | 249 } |
250 | 250 |
251 void ClientSideDetectionService::StartFetchModel() { | 251 void ClientSideDetectionService::StartFetchModel() { |
252 if (enabled_) { | 252 if (enabled_) { |
253 // Start fetching the model either from the cache or possibly from the | 253 // Start fetching the model either from the cache or possibly from the |
254 // network if the model isn't in the cache. | 254 // network if the model isn't in the cache. |
255 model_fetcher_.reset(content::URLFetcher::Create( | 255 model_fetcher_.reset(content::URLFetcher::Create( |
256 0 /* ID used for testing */, GURL(kClientModelUrl), | 256 0 /* ID used for testing */, GURL(kClientModelUrl), |
257 content::URLFetcher::GET, this)); | 257 content::URLFetcher::GET, this)); |
258 model_fetcher_->SetRequestContext(request_context_getter_.get()); | 258 model_fetcher_->SetRequestContext(request_context_getter_.get()); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 524 } |
525 } | 525 } |
526 for (int i = 0; i < model.page_term_size(); ++i) { | 526 for (int i = 0; i < model.page_term_size(); ++i) { |
527 if (model.page_term(i) < 0 || model.page_term(i) > max_index) { | 527 if (model.page_term(i) < 0 || model.page_term(i) > max_index) { |
528 return false; | 528 return false; |
529 } | 529 } |
530 } | 530 } |
531 return true; | 531 return true; |
532 } | 532 } |
533 } // namespace safe_browsing | 533 } // namespace safe_browsing |
OLD | NEW |