| 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/extensions/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } | 807 } |
| 808 std::vector<std::string> blacklist; | 808 std::vector<std::string> blacklist; |
| 809 base::SplitString(data, '\n', &blacklist); | 809 base::SplitString(data, '\n', &blacklist); |
| 810 | 810 |
| 811 // Tell ExtensionService to update prefs. | 811 // Tell ExtensionService to update prefs. |
| 812 service_->UpdateExtensionBlacklist(blacklist); | 812 service_->UpdateExtensionBlacklist(blacklist); |
| 813 | 813 |
| 814 // Update the pref value for blacklist version | 814 // Update the pref value for blacklist version |
| 815 prefs_->SetString(kExtensionBlacklistUpdateVersion, | 815 prefs_->SetString(kExtensionBlacklistUpdateVersion, |
| 816 current_extension_fetch_.version); | 816 current_extension_fetch_.version); |
| 817 prefs_->ScheduleSavePersistentPrefs(); | |
| 818 } | 817 } |
| 819 | 818 |
| 820 void ExtensionUpdater::OnCRXFetchComplete( | 819 void ExtensionUpdater::OnCRXFetchComplete( |
| 821 const URLFetcher* source, | 820 const URLFetcher* source, |
| 822 const GURL& url, | 821 const GURL& url, |
| 823 const net::URLRequestStatus& status, | 822 const net::URLRequestStatus& status, |
| 824 int response_code) { | 823 int response_code) { |
| 825 | 824 |
| 826 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; | 825 base::PlatformFileError error_code = base::PLATFORM_FILE_OK; |
| 827 if (source->FileErrorOccurred(&error_code)) { | 826 if (source->FileErrorOccurred(&error_code)) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 // Add +/- 10% random jitter. | 931 // Add +/- 10% random jitter. |
| 933 double delay_ms = target_delay.InMillisecondsF(); | 932 double delay_ms = target_delay.InMillisecondsF(); |
| 934 double jitter_factor = (RandDouble() * .2) - 0.1; | 933 double jitter_factor = (RandDouble() * .2) - 0.1; |
| 935 delay_ms += delay_ms * jitter_factor; | 934 delay_ms += delay_ms * jitter_factor; |
| 936 TimeDelta actual_delay = TimeDelta::FromMilliseconds( | 935 TimeDelta actual_delay = TimeDelta::FromMilliseconds( |
| 937 static_cast<int64>(delay_ms)); | 936 static_cast<int64>(delay_ms)); |
| 938 | 937 |
| 939 // Save the time of next check. | 938 // Save the time of next check. |
| 940 Time next = Time::Now() + actual_delay; | 939 Time next = Time::Now() + actual_delay; |
| 941 prefs_->SetInt64(kNextExtensionsUpdateCheck, next.ToInternalValue()); | 940 prefs_->SetInt64(kNextExtensionsUpdateCheck, next.ToInternalValue()); |
| 942 prefs_->ScheduleSavePersistentPrefs(); | |
| 943 | 941 |
| 944 timer_.Start(FROM_HERE, actual_delay, this, &ExtensionUpdater::TimerFired); | 942 timer_.Start(FROM_HERE, actual_delay, this, &ExtensionUpdater::TimerFired); |
| 945 } | 943 } |
| 946 | 944 |
| 947 void ExtensionUpdater::TimerFired() { | 945 void ExtensionUpdater::TimerFired() { |
| 948 DCHECK(alive_); | 946 DCHECK(alive_); |
| 949 CheckNow(); | 947 CheckNow(); |
| 950 | 948 |
| 951 // If the user has overridden the update frequency, don't bother reporting | 949 // If the user has overridden the update frequency, don't bother reporting |
| 952 // this. | 950 // this. |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 std::set<std::string>::const_iterator i; | 1234 std::set<std::string>::const_iterator i; |
| 1237 for (i = ids.begin(); i != ids.end(); ++i) | 1235 for (i = ids.begin(); i != ids.end(); ++i) |
| 1238 in_progress_ids_.insert(*i); | 1236 in_progress_ids_.insert(*i); |
| 1239 } | 1237 } |
| 1240 | 1238 |
| 1241 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1239 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
| 1242 std::set<std::string>::const_iterator i; | 1240 std::set<std::string>::const_iterator i; |
| 1243 for (i = ids.begin(); i != ids.end(); ++i) | 1241 for (i = ids.begin(); i != ids.end(); ++i) |
| 1244 in_progress_ids_.erase(*i); | 1242 in_progress_ids_.erase(*i); |
| 1245 } | 1243 } |
| OLD | NEW |