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

Side by Side Diff: components/google/core/browser/google_url_tracker.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/google/core/browser/google_url_tracker.h" 5 #include "components/google/core/browser/google_url_tracker.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/location.h"
9 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/thread_task_runner_handle.h"
11 #include "components/google/core/browser/google_pref_names.h" 14 #include "components/google/core/browser/google_pref_names.h"
12 #include "components/google/core/browser/google_switches.h" 15 #include "components/google/core/browser/google_switches.h"
13 #include "components/google/core/browser/google_util.h" 16 #include "components/google/core/browser/google_util.h"
14 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
15 #include "net/url_request/url_fetcher.h" 18 #include "net/url_request/url_fetcher.h"
16 #include "net/url_request/url_request_status.h" 19 #include "net/url_request/url_request_status.h"
17 20
18 21
19 const char GoogleURLTracker::kDefaultGoogleHomepage[] = 22 const char GoogleURLTracker::kDefaultGoogleHomepage[] =
20 "https://www.google.com/"; 23 "https://www.google.com/";
(...skipping 18 matching lines...) Expand all
39 // fetch can eat up 20 ms of time, we delay five seconds, which is hopefully 42 // fetch can eat up 20 ms of time, we delay five seconds, which is hopefully
40 // long enough to be after startup, but still get results back quickly. 43 // long enough to be after startup, but still get results back quickly.
41 // Ideally, instead of this timer, we'd do something like "check if the 44 // Ideally, instead of this timer, we'd do something like "check if the
42 // browser is starting up, and if so, come back later", but there is currently 45 // browser is starting up, and if so, come back later", but there is currently
43 // no function to do this. 46 // no function to do this.
44 // 47 //
45 // In UNIT_TEST_MODE, where we want to explicitly control when the tracker 48 // In UNIT_TEST_MODE, where we want to explicitly control when the tracker
46 // "wakes up", we do nothing at all. 49 // "wakes up", we do nothing at all.
47 if (mode == NORMAL_MODE) { 50 if (mode == NORMAL_MODE) {
48 static const int kStartFetchDelayMS = 5000; 51 static const int kStartFetchDelayMS = 5000;
49 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, 52 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
50 base::Bind(&GoogleURLTracker::FinishSleep, 53 FROM_HERE, base::Bind(&GoogleURLTracker::FinishSleep,
51 weak_ptr_factory_.GetWeakPtr()), 54 weak_ptr_factory_.GetWeakPtr()),
52 base::TimeDelta::FromMilliseconds(kStartFetchDelayMS)); 55 base::TimeDelta::FromMilliseconds(kStartFetchDelayMS));
53 } 56 }
54 } 57 }
55 58
56 GoogleURLTracker::~GoogleURLTracker() { 59 GoogleURLTracker::~GoogleURLTracker() {
57 } 60 }
58 61
59 void GoogleURLTracker::RequestServerCheck(bool force) { 62 void GoogleURLTracker::RequestServerCheck(bool force) {
60 // If this instance already has a fetcher, SetNeedToFetch() is unnecessary, 63 // If this instance already has a fetcher, SetNeedToFetch() is unnecessary,
61 // and changing |already_fetched_| is wrong. 64 // and changing |already_fetched_| is wrong.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Also retry kMaxRetries times on network change errors. A network change can 167 // Also retry kMaxRetries times on network change errors. A network change can
165 // propagate through Chrome in various stages, so it's possible for this code 168 // propagate through Chrome in various stages, so it's possible for this code
166 // to be reached via OnNetworkChanged(), and then have the fetch we kick off 169 // to be reached via OnNetworkChanged(), and then have the fetch we kick off
167 // be canceled due to e.g. the DNS server changing at a later time. In general 170 // be canceled due to e.g. the DNS server changing at a later time. In general
168 // it's not possible to ensure that by the time we reach here any requests we 171 // it's not possible to ensure that by the time we reach here any requests we
169 // start won't be canceled in this fashion, so retrying is the best we can do. 172 // start won't be canceled in this fashion, so retrying is the best we can do.
170 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); 173 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries);
171 174
172 fetcher_->Start(); 175 fetcher_->Start();
173 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698