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

Side by Side Diff: webkit/appcache/appcache_update_job.cc

Issue 3076005: A better error message for the mime type of a manifest file being off.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/appcache/appcache_update_job.h" 5 #include "webkit/appcache/appcache_update_job.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 delete request; 500 delete request;
501 return true; 501 return true;
502 } 502 }
503 503
504 void AppCacheUpdateJob::HandleManifestFetchCompleted(URLRequest* request) { 504 void AppCacheUpdateJob::HandleManifestFetchCompleted(URLRequest* request) {
505 DCHECK(internal_state_ == FETCH_MANIFEST); 505 DCHECK(internal_state_ == FETCH_MANIFEST);
506 manifest_url_request_ = NULL; 506 manifest_url_request_ = NULL;
507 507
508 int response_code = -1; 508 int response_code = -1;
509 std::string mime_type; 509 std::string mime_type;
510 bool is_valid_response_code = false;
511 bool is_valid_mime_type = false;
510 if (request->status().is_success()) { 512 if (request->status().is_success()) {
511 response_code = request->GetResponseCode(); 513 response_code = request->GetResponseCode();
514 is_valid_response_code = (response_code / 100 == 2);
512 request->GetMimeType(&mime_type); 515 request->GetMimeType(&mime_type);
516 is_valid_mime_type = (mime_type == kManifestMimeType);
513 } 517 }
514 518
515 if ((response_code / 100 == 2) && mime_type == kManifestMimeType) { 519 if (is_valid_response_code && is_valid_mime_type) {
516 manifest_response_info_.reset( 520 manifest_response_info_.reset(
517 new net::HttpResponseInfo(request->response_info())); 521 new net::HttpResponseInfo(request->response_info()));
518 if (update_type_ == UPGRADE_ATTEMPT) 522 if (update_type_ == UPGRADE_ATTEMPT)
519 CheckIfManifestChanged(); // continues asynchronously 523 CheckIfManifestChanged(); // continues asynchronously
520 else 524 else
521 ContinueHandleManifestFetchCompleted(true); 525 ContinueHandleManifestFetchCompleted(true);
522 } else if (response_code == 304 && update_type_ == UPGRADE_ATTEMPT) { 526 } else if (response_code == 304 && update_type_ == UPGRADE_ATTEMPT) {
523 ContinueHandleManifestFetchCompleted(false); 527 ContinueHandleManifestFetchCompleted(false);
524 } else if (response_code == 404 || response_code == 410) { 528 } else if (response_code == 404 || response_code == 410) {
525 service_->storage()->MakeGroupObsolete(group_, this); // async 529 service_->storage()->MakeGroupObsolete(group_, this); // async
526 } else { 530 } else {
527 const char* kFormatString = "Manifest fetch failed (%d) %s"; 531 std::string message;
528 const std::string message = StringPrintf(kFormatString, response_code, 532 if (!is_valid_response_code) {
529 manifest_url_.spec().c_str()); 533 const char* kFormatString = "Manifest fetch failed (%d) %s";
534 message = StringPrintf(kFormatString, response_code,
535 manifest_url_.spec().c_str());
536 } else {
537 DCHECK(!is_valid_mime_type);
538 const char* kFormatString = "Invalid manifest mime type (%s) %s";
539 message = StringPrintf(kFormatString, mime_type.c_str(),
540 manifest_url_.spec().c_str());
541 }
530 HandleCacheFailure(message); 542 HandleCacheFailure(message);
531 } 543 }
532 } 544 }
533 545
534 void AppCacheUpdateJob::OnGroupMadeObsolete(AppCacheGroup* group, 546 void AppCacheUpdateJob::OnGroupMadeObsolete(AppCacheGroup* group,
535 bool success) { 547 bool success) {
536 DCHECK(master_entry_fetches_.empty()); 548 DCHECK(master_entry_fetches_.empty());
537 CancelAllMasterEntryFetches("The group has been made obsolete"); 549 CancelAllMasterEntryFetches("The group has been made obsolete");
538 if (success) { 550 if (success) {
539 DCHECK(group->is_obsolete()); 551 DCHECK(group->is_obsolete());
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1376
1365 // Break the connection with the group so the group cannot call delete 1377 // Break the connection with the group so the group cannot call delete
1366 // on this object after we've posted a task to delete ourselves. 1378 // on this object after we've posted a task to delete ourselves.
1367 group_->SetUpdateStatus(AppCacheGroup::IDLE); 1379 group_->SetUpdateStatus(AppCacheGroup::IDLE);
1368 group_ = NULL; 1380 group_ = NULL;
1369 1381
1370 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1382 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1371 } 1383 }
1372 1384
1373 } // namespace appcache 1385 } // namespace appcache
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698