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

Side by Side Diff: rlz/lib/financial_ping.cc

Issue 2033863003: Remove use of deprecated MessageLoop methods in rlz. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Library functions related to the Financial Server ping. 5 // Library functions related to the Financial Server ping.
6 6
7 #include "rlz/lib/financial_ping.h" 7 #include "rlz/lib/financial_ping.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/location.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/threading/thread_task_runner_handle.h"
19 #include "build/build_config.h" 22 #include "build/build_config.h"
20 #include "rlz/lib/assert.h" 23 #include "rlz/lib/assert.h"
21 #include "rlz/lib/lib_values.h" 24 #include "rlz/lib/lib_values.h"
22 #include "rlz/lib/machine_id.h" 25 #include "rlz/lib/machine_id.h"
23 #include "rlz/lib/rlz_lib.h" 26 #include "rlz/lib/rlz_lib.h"
24 #include "rlz/lib/rlz_value_store.h" 27 #include "rlz/lib/rlz_value_store.h"
25 #include "rlz/lib/string_utils.h" 28 #include "rlz/lib/string_utils.h"
26 29
27 #if !defined(OS_WIN) 30 #if !defined(OS_WIN)
28 #include "base/time/time.h" 31 #include "base/time/time.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (!weak.get()) 226 if (!weak.get())
224 return; 227 return;
225 if (!base::subtle::Acquire_Load(&g_context)) { 228 if (!base::subtle::Acquire_Load(&g_context)) {
226 send_financial_ping_interrupted_for_test = true; 229 send_financial_ping_interrupted_for_test = true;
227 weak->QuitClosure().Run(); 230 weak->QuitClosure().Run();
228 return; 231 return;
229 } 232 }
230 // How frequently the financial ping thread should check 233 // How frequently the financial ping thread should check
231 // the shutdown condition? 234 // the shutdown condition?
232 const base::TimeDelta kInterval = base::TimeDelta::FromMilliseconds(500); 235 const base::TimeDelta kInterval = base::TimeDelta::FromMilliseconds(500);
233 base::MessageLoop::current()->PostDelayedTask( 236 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
234 FROM_HERE, 237 FROM_HERE, base::Bind(&ShutdownCheck, weak), kInterval);
235 base::Bind(&ShutdownCheck, weak),
236 kInterval);
237 } 238 }
238 #endif 239 #endif
239 240
240 bool FinancialPing::PingServer(const char* request, std::string* response) { 241 bool FinancialPing::PingServer(const char* request, std::string* response) {
241 if (!response) 242 if (!response)
242 return false; 243 return false;
243 244
244 response->clear(); 245 response->clear();
245 246
246 #if defined(RLZ_NETWORK_IMPLEMENTATION_WIN_INET) 247 #if defined(RLZ_NETWORK_IMPLEMENTATION_WIN_INET)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 328
328 // Ensure rlz_lib::SetURLRequestContext() has been called before sending 329 // Ensure rlz_lib::SetURLRequestContext() has been called before sending
329 // pings. 330 // pings.
330 fetcher->SetRequestContext(context); 331 fetcher->SetRequestContext(context);
331 332
332 base::WeakPtrFactory<base::RunLoop> weak(&loop); 333 base::WeakPtrFactory<base::RunLoop> weak(&loop);
333 334
334 const base::TimeDelta kTimeout = base::TimeDelta::FromMinutes(5); 335 const base::TimeDelta kTimeout = base::TimeDelta::FromMinutes(5);
335 base::MessageLoop::ScopedNestableTaskAllower allow_nested( 336 base::MessageLoop::ScopedNestableTaskAllower allow_nested(
336 base::MessageLoop::current()); 337 base::MessageLoop::current());
337 base::MessageLoop::current()->PostTask( 338 base::ThreadTaskRunnerHandle::Get()->PostTask(
338 FROM_HERE, 339 FROM_HERE, base::Bind(&ShutdownCheck, weak.GetWeakPtr()));
339 base::Bind(&ShutdownCheck, weak.GetWeakPtr())); 340 base::ThreadTaskRunnerHandle::Get()->PostTask(
340 base::MessageLoop::current()->PostTask(
341 FROM_HERE, 341 FROM_HERE,
342 base::Bind(&net::URLFetcher::Start, base::Unretained(fetcher.get()))); 342 base::Bind(&net::URLFetcher::Start, base::Unretained(fetcher.get())));
343 base::MessageLoop::current()->PostDelayedTask( 343 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
344 FROM_HERE, loop.QuitClosure(), kTimeout); 344 FROM_HERE, loop.QuitClosure(), kTimeout);
345 345
346 loop.Run(); 346 loop.Run();
347 347
348 if (fetcher->GetResponseCode() != 200) 348 if (fetcher->GetResponseCode() != 200)
349 return false; 349 return false;
350 350
351 return fetcher->GetResponseAsString(response); 351 return fetcher->GetResponseAsString(response);
352 #endif 352 #endif
353 } 353 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 407 }
408 408
409 bool WasSendFinancialPingInterrupted() { 409 bool WasSendFinancialPingInterrupted() {
410 return send_financial_ping_interrupted_for_test; 410 return send_financial_ping_interrupted_for_test;
411 } 411 }
412 412
413 } // namespace test 413 } // namespace test
414 #endif 414 #endif
415 415
416 } // namespace rlz_lib 416 } // namespace rlz_lib
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698