| 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/safe_browsing/protocol_manager.h" | 5 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 6 | 6 |
| 7 #ifndef NDEBUG | 7 #ifndef NDEBUG |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #endif | 9 #endif |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // so that it doesn't hold up the user's request indefinitely. Not sure | 256 // so that it doesn't hold up the user's request indefinitely. Not sure |
| 257 // what to do at that point though! | 257 // what to do at that point though! |
| 258 full_hashes.clear(); | 258 full_hashes.clear(); |
| 259 } else { | 259 } else { |
| 260 if (re_key) | 260 if (re_key) |
| 261 HandleReKey(); | 261 HandleReKey(); |
| 262 } | 262 } |
| 263 } else { | 263 } else { |
| 264 HandleGetHashError(Time::Now()); | 264 HandleGetHashError(Time::Now()); |
| 265 if (source->GetStatus().status() == net::URLRequestStatus::FAILED) { | 265 if (source->GetStatus().status() == net::URLRequestStatus::FAILED) { |
| 266 VLOG(1) << "SafeBrowsing GetHash request for: " << source->GetUrl() | 266 VLOG(1) << "SafeBrowsing GetHash request for: " << source->GetURL() |
| 267 << " failed with error: " << source->GetStatus().error(); | 267 << " failed with error: " << source->GetStatus().error(); |
| 268 } else { | 268 } else { |
| 269 VLOG(1) << "SafeBrowsing GetHash request for: " << source->GetUrl() | 269 VLOG(1) << "SafeBrowsing GetHash request for: " << source->GetURL() |
| 270 << " failed with error: " << source->GetResponseCode(); | 270 << " failed with error: " << source->GetResponseCode(); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Call back the SafeBrowsingService with full_hashes, even if there was a | 274 // Call back the SafeBrowsingService with full_hashes, even if there was a |
| 275 // parse error or an error response code (in which case full_hashes will be | 275 // parse error or an error response code (in which case full_hashes will be |
| 276 // empty). We can't block the user regardless of the error status. | 276 // empty). We can't block the user regardless of the error status. |
| 277 sb_service_->HandleGetHashResults(check, full_hashes, can_cache); | 277 sb_service_->HandleGetHashResults(check, full_hashes, can_cache); |
| 278 | 278 |
| 279 hash_requests_.erase(it); | 279 hash_requests_.erase(it); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 290 | 290 |
| 291 // Cancel the update response timeout now that we have the response. | 291 // Cancel the update response timeout now that we have the response. |
| 292 update_timer_.Stop(); | 292 update_timer_.Stop(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 if (source->GetResponseCode() == 200) { | 295 if (source->GetResponseCode() == 200) { |
| 296 // We have data from the SafeBrowsing service. | 296 // We have data from the SafeBrowsing service. |
| 297 std::string data; | 297 std::string data; |
| 298 source->GetResponseAsString(&data); | 298 source->GetResponseAsString(&data); |
| 299 parsed_ok = HandleServiceResponse( | 299 parsed_ok = HandleServiceResponse( |
| 300 source->GetUrl(), data.data(), static_cast<int>(data.length())); | 300 source->GetURL(), data.data(), static_cast<int>(data.length())); |
| 301 if (!parsed_ok) { | 301 if (!parsed_ok) { |
| 302 VLOG(1) << "SafeBrowsing request for: " << source->GetUrl() | 302 VLOG(1) << "SafeBrowsing request for: " << source->GetURL() |
| 303 << " failed parse."; | 303 << " failed parse."; |
| 304 must_back_off = true; | 304 must_back_off = true; |
| 305 chunk_request_urls_.clear(); | 305 chunk_request_urls_.clear(); |
| 306 UpdateFinished(false); | 306 UpdateFinished(false); |
| 307 } | 307 } |
| 308 | 308 |
| 309 switch (request_type_) { | 309 switch (request_type_) { |
| 310 case CHUNK_REQUEST: | 310 case CHUNK_REQUEST: |
| 311 if (parsed_ok) | 311 if (parsed_ok) |
| 312 chunk_request_urls_.pop_front(); | 312 chunk_request_urls_.pop_front(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 331 NOTREACHED(); | 331 NOTREACHED(); |
| 332 break; | 332 break; |
| 333 } | 333 } |
| 334 } else { | 334 } else { |
| 335 // The SafeBrowsing service error, or very bad response code: back off. | 335 // The SafeBrowsing service error, or very bad response code: back off. |
| 336 must_back_off = true; | 336 must_back_off = true; |
| 337 if (request_type_ == CHUNK_REQUEST) | 337 if (request_type_ == CHUNK_REQUEST) |
| 338 chunk_request_urls_.clear(); | 338 chunk_request_urls_.clear(); |
| 339 UpdateFinished(false); | 339 UpdateFinished(false); |
| 340 if (source->GetStatus().status() == net::URLRequestStatus::FAILED) { | 340 if (source->GetStatus().status() == net::URLRequestStatus::FAILED) { |
| 341 VLOG(1) << "SafeBrowsing request for: " << source->GetUrl() | 341 VLOG(1) << "SafeBrowsing request for: " << source->GetURL() |
| 342 << " failed with error: " << source->GetStatus().error(); | 342 << " failed with error: " << source->GetStatus().error(); |
| 343 } else { | 343 } else { |
| 344 VLOG(1) << "SafeBrowsing request for: " << source->GetUrl() | 344 VLOG(1) << "SafeBrowsing request for: " << source->GetURL() |
| 345 << " failed with error: " << source->GetResponseCode(); | 345 << " failed with error: " << source->GetResponseCode(); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Schedule a new update request if we've finished retrieving all the chunks | 350 // Schedule a new update request if we've finished retrieving all the chunks |
| 351 // from the previous update. We treat the update request and the chunk URLs it | 351 // from the previous update. We treat the update request and the chunk URLs it |
| 352 // contains as an atomic unit as far as back off is concerned. | 352 // contains as an atomic unit as far as back off is concerned. |
| 353 if (chunk_request_urls_.empty() && | 353 if (chunk_request_urls_.empty() && |
| 354 (request_type_ == CHUNK_REQUEST || request_type_ == UPDATE_REQUEST)) | 354 (request_type_ == CHUNK_REQUEST || request_type_ == UPDATE_REQUEST)) |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 if (!additional_query_.empty()) { | 832 if (!additional_query_.empty()) { |
| 833 if (next_url.find("?") != std::string::npos) { | 833 if (next_url.find("?") != std::string::npos) { |
| 834 next_url.append("&"); | 834 next_url.append("&"); |
| 835 } else { | 835 } else { |
| 836 next_url.append("?"); | 836 next_url.append("?"); |
| 837 } | 837 } |
| 838 next_url.append(additional_query_); | 838 next_url.append(additional_query_); |
| 839 } | 839 } |
| 840 return GURL(next_url); | 840 return GURL(next_url); |
| 841 } | 841 } |
| OLD | NEW |