Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: chrome/browser/safe_browsing/client_side_model_loader.cc

Issue 2033753002: Remove use of deprecated MessageLoop methods in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual change Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/time/time.h" 17 #include "base/time/time.h"
16 #include "chrome/browser/safe_browsing/protocol_manager.h" 18 #include "chrome/browser/safe_browsing/protocol_manager.h"
17 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/safe_browsing/client_model.pb.h" 20 #include "chrome/common/safe_browsing/client_model.pb.h"
19 #include "chrome/common/safe_browsing/csd.pb.h" 21 #include "chrome/common/safe_browsing/csd.pb.h"
20 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 22 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
21 #include "components/variations/variations_associated_data.h" 23 #include "components/variations/variations_associated_data.h"
22 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
23 #include "net/http/http_status_code.h" 25 #include "net/http/http_status_code.h"
24 #include "net/url_request/url_fetcher.h" 26 #include "net/url_request/url_fetcher.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 187 }
186 188
187 // Schedule the next model reload. 189 // Schedule the next model reload.
188 ScheduleFetch(delay_ms); 190 ScheduleFetch(delay_ms);
189 } 191 }
190 192
191 void ModelLoader::ScheduleFetch(int64_t delay_ms) { 193 void ModelLoader::ScheduleFetch(int64_t delay_ms) {
192 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 194 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
193 switches::kSbDisableAutoUpdate)) 195 switches::kSbDisableAutoUpdate))
194 return; 196 return;
195 base::MessageLoop::current()->PostDelayedTask( 197 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
196 FROM_HERE, 198 FROM_HERE,
197 base::Bind(&ModelLoader::StartFetch, weak_factory_.GetWeakPtr()), 199 base::Bind(&ModelLoader::StartFetch, weak_factory_.GetWeakPtr()),
198 base::TimeDelta::FromMilliseconds(delay_ms)); 200 base::TimeDelta::FromMilliseconds(delay_ms));
199 } 201 }
200 202
201 void ModelLoader::CancelFetcher() { 203 void ModelLoader::CancelFetcher() {
202 // Invalidate any scheduled request. 204 // Invalidate any scheduled request.
203 weak_factory_.InvalidateWeakPtrs(); 205 weak_factory_.InvalidateWeakPtrs();
204 // Cancel any request in progress. 206 // Cancel any request in progress.
205 fetcher_.reset(); 207 fetcher_.reset();
206 } 208 }
207 209
208 } // namespace safe_browsing 210 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_window.cc ('k') | chrome/browser/safe_browsing/download_protection_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698