| OLD | NEW |
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 | 67 |
| 68 // static | 68 // static |
| 69 void GoogleURLTracker::RegisterProfilePrefs( | 69 void GoogleURLTracker::RegisterProfilePrefs( |
| 70 user_prefs::PrefRegistrySyncable* registry) { | 70 user_prefs::PrefRegistrySyncable* registry) { |
| 71 registry->RegisterStringPref(prefs::kLastKnownGoogleURL, | 71 registry->RegisterStringPref(prefs::kLastKnownGoogleURL, |
| 72 GoogleURLTracker::kDefaultGoogleHomepage); | 72 GoogleURLTracker::kDefaultGoogleHomepage); |
| 73 registry->RegisterStringPref(prefs::kLastPromptedGoogleURL, std::string()); | 73 registry->RegisterStringPref(prefs::kLastPromptedGoogleURL, std::string()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void GoogleURLTracker::RequestServerCheck(bool force) { | 76 void GoogleURLTracker::RequestServerCheck() { |
| 77 // If this instance already has a fetcher, SetNeedToFetch() is unnecessary, | 77 if (!fetcher_) |
| 78 // and changing |already_fetched_| is wrong. | |
| 79 if (!fetcher_) { | |
| 80 if (force) | |
| 81 already_fetched_ = false; | |
| 82 SetNeedToFetch(); | 78 SetNeedToFetch(); |
| 83 } | |
| 84 } | 79 } |
| 85 | 80 |
| 86 std::unique_ptr<GoogleURLTracker::Subscription> | 81 std::unique_ptr<GoogleURLTracker::Subscription> |
| 87 GoogleURLTracker::RegisterCallback(const OnGoogleURLUpdatedCallback& cb) { | 82 GoogleURLTracker::RegisterCallback(const OnGoogleURLUpdatedCallback& cb) { |
| 88 return callback_list_.Add(cb); | 83 return callback_list_.Add(cb); |
| 89 } | 84 } |
| 90 | 85 |
| 91 void GoogleURLTracker::OnURLFetchComplete(const net::URLFetcher* source) { | 86 void GoogleURLTracker::OnURLFetchComplete(const net::URLFetcher* source) { |
| 92 // Delete the fetcher on this function's exit. | 87 // Delete the fetcher on this function's exit. |
| 93 std::unique_ptr<net::URLFetcher> clean_up_fetcher(std::move(fetcher_)); | 88 std::unique_ptr<net::URLFetcher> clean_up_fetcher(std::move(fetcher_)); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Also retry kMaxRetries times on network change errors. A network change can | 180 // Also retry kMaxRetries times on network change errors. A network change can |
| 186 // propagate through Chrome in various stages, so it's possible for this code | 181 // propagate through Chrome in various stages, so it's possible for this code |
| 187 // to be reached via OnNetworkChanged(), and then have the fetch we kick off | 182 // to be reached via OnNetworkChanged(), and then have the fetch we kick off |
| 188 // be canceled due to e.g. the DNS server changing at a later time. In general | 183 // be canceled due to e.g. the DNS server changing at a later time. In general |
| 189 // it's not possible to ensure that by the time we reach here any requests we | 184 // it's not possible to ensure that by the time we reach here any requests we |
| 190 // start won't be canceled in this fashion, so retrying is the best we can do. | 185 // start won't be canceled in this fashion, so retrying is the best we can do. |
| 191 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); | 186 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); |
| 192 | 187 |
| 193 fetcher_->Start(); | 188 fetcher_->Start(); |
| 194 } | 189 } |
| OLD | NEW |