| OLD | NEW |
| 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/net/crl_set_fetcher.h" | 5 #include "chrome/browser/net/crl_set_fetcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 LOG(WARNING) << "GetIsDeltaUpdate failed on CRL set from update CRX"; | 164 LOG(WARNING) << "GetIsDeltaUpdate failed on CRL set from update CRX"; |
| 165 return false; | 165 return false; |
| 166 } | 166 } |
| 167 | 167 |
| 168 if (!is_delta) { | 168 if (!is_delta) { |
| 169 if (!net::CRLSet::Parse(crl_set_bytes, &crl_set_)) { | 169 if (!net::CRLSet::Parse(crl_set_bytes, &crl_set_)) { |
| 170 LOG(WARNING) << "Failed to parse CRL set from update CRX"; | 170 LOG(WARNING) << "Failed to parse CRL set from update CRX"; |
| 171 return false; | 171 return false; |
| 172 } | 172 } |
| 173 int size = base::checked_cast<int>(crl_set_bytes.size()); | 173 int size = base::checked_cast<int>(crl_set_bytes.size()); |
| 174 if (file_util::WriteFile(save_to, crl_set_bytes.data(), size) != size) { | 174 if (base::WriteFile(save_to, crl_set_bytes.data(), size) != size) { |
| 175 LOG(WARNING) << "Failed to save new CRL set to disk"; | 175 LOG(WARNING) << "Failed to save new CRL set to disk"; |
| 176 // We don't return false here because we can still use this CRL set. When | 176 // We don't return false here because we can still use this CRL set. When |
| 177 // we restart we might revert to an older version, then we'll | 177 // we restart we might revert to an older version, then we'll |
| 178 // advertise the older version to Omaha and everything will still work. | 178 // advertise the older version to Omaha and everything will still work. |
| 179 } | 179 } |
| 180 } else { | 180 } else { |
| 181 scoped_refptr<net::CRLSet> new_crl_set; | 181 scoped_refptr<net::CRLSet> new_crl_set; |
| 182 if (!crl_set_->ApplyDelta(crl_set_bytes, &new_crl_set)) { | 182 if (!crl_set_->ApplyDelta(crl_set_bytes, &new_crl_set)) { |
| 183 LOG(WARNING) << "Failed to parse delta CRL set"; | 183 LOG(WARNING) << "Failed to parse delta CRL set"; |
| 184 return false; | 184 return false; |
| 185 } | 185 } |
| 186 VLOG(1) << "Applied CRL set delta #" << crl_set_->sequence() | 186 VLOG(1) << "Applied CRL set delta #" << crl_set_->sequence() |
| 187 << "->#" << new_crl_set->sequence(); | 187 << "->#" << new_crl_set->sequence(); |
| 188 const std::string new_crl_set_bytes = new_crl_set->Serialize(); | 188 const std::string new_crl_set_bytes = new_crl_set->Serialize(); |
| 189 int size = base::checked_cast<int>(new_crl_set_bytes.size()); | 189 int size = base::checked_cast<int>(new_crl_set_bytes.size()); |
| 190 if (file_util::WriteFile(save_to, new_crl_set_bytes.data(), size) != size) { | 190 if (base::WriteFile(save_to, new_crl_set_bytes.data(), size) != size) { |
| 191 LOG(WARNING) << "Failed to save new CRL set to disk"; | 191 LOG(WARNING) << "Failed to save new CRL set to disk"; |
| 192 // We don't return false here because we can still use this CRL set. When | 192 // We don't return false here because we can still use this CRL set. When |
| 193 // we restart we might revert to an older version, then we'll | 193 // we restart we might revert to an older version, then we'll |
| 194 // advertise the older version to Omaha and everything will still work. | 194 // advertise the older version to Omaha and everything will still work. |
| 195 } | 195 } |
| 196 crl_set_ = new_crl_set; | 196 crl_set_ = new_crl_set; |
| 197 } | 197 } |
| 198 | 198 |
| 199 if (!BrowserThread::PostTask( | 199 if (!BrowserThread::PostTask( |
| 200 BrowserThread::IO, FROM_HERE, | 200 BrowserThread::IO, FROM_HERE, |
| 201 base::Bind( | 201 base::Bind( |
| 202 &CRLSetFetcher::SetCRLSetIfNewer, this, crl_set_))) { | 202 &CRLSetFetcher::SetCRLSetIfNewer, this, crl_set_))) { |
| 203 NOTREACHED(); | 203 NOTREACHED(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 return true; | 206 return true; |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool CRLSetFetcher::GetInstalledFile( | 209 bool CRLSetFetcher::GetInstalledFile( |
| 210 const std::string& file, base::FilePath* installed_file) { | 210 const std::string& file, base::FilePath* installed_file) { |
| 211 return false; | 211 return false; |
| 212 } | 212 } |
| 213 | 213 |
| 214 CRLSetFetcher::~CRLSetFetcher() {} | 214 CRLSetFetcher::~CRLSetFetcher() {} |
| OLD | NEW |