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

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

Issue 8566020: No longer check for a specific mime-type on appcache manifest files. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « webkit/appcache/appcache_interfaces.cc ('k') | webkit/appcache/appcache_update_job_unittest.cc » ('j') | 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) 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 "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 "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 432
433 void AppCacheUpdateJob::HandleManifestFetchCompleted( 433 void AppCacheUpdateJob::HandleManifestFetchCompleted(
434 URLFetcher* fetcher) { 434 URLFetcher* fetcher) {
435 DCHECK_EQ(internal_state_, FETCH_MANIFEST); 435 DCHECK_EQ(internal_state_, FETCH_MANIFEST);
436 DCHECK_EQ(manifest_fetcher_, fetcher); 436 DCHECK_EQ(manifest_fetcher_, fetcher);
437 manifest_fetcher_ = NULL; 437 manifest_fetcher_ = NULL;
438 438
439 net::URLRequest* request = fetcher->request(); 439 net::URLRequest* request = fetcher->request();
440 int response_code = -1; 440 int response_code = -1;
441 std::string mime_type;
442 bool is_valid_response_code = false; 441 bool is_valid_response_code = false;
443 bool is_valid_mime_type = false;
444 if (request->status().is_success()) { 442 if (request->status().is_success()) {
445 response_code = request->GetResponseCode(); 443 response_code = request->GetResponseCode();
446 is_valid_response_code = (response_code / 100 == 2); 444 is_valid_response_code = (response_code / 100 == 2);
447 request->GetMimeType(&mime_type);
448 is_valid_mime_type = (mime_type == kManifestMimeType);
449 } 445 }
450 446
451 if (is_valid_response_code && is_valid_mime_type) { 447 if (is_valid_response_code) {
452 manifest_data_ = fetcher->manifest_data(); 448 manifest_data_ = fetcher->manifest_data();
453 manifest_response_info_.reset( 449 manifest_response_info_.reset(
454 new net::HttpResponseInfo(request->response_info())); 450 new net::HttpResponseInfo(request->response_info()));
455 if (update_type_ == UPGRADE_ATTEMPT) 451 if (update_type_ == UPGRADE_ATTEMPT)
456 CheckIfManifestChanged(); // continues asynchronously 452 CheckIfManifestChanged(); // continues asynchronously
457 else 453 else
458 ContinueHandleManifestFetchCompleted(true); 454 ContinueHandleManifestFetchCompleted(true);
459 } else if (response_code == 304 && update_type_ == UPGRADE_ATTEMPT) { 455 } else if (response_code == 304 && update_type_ == UPGRADE_ATTEMPT) {
460 ContinueHandleManifestFetchCompleted(false); 456 ContinueHandleManifestFetchCompleted(false);
461 } else if ((response_code == 404 || response_code == 410) && 457 } else if ((response_code == 404 || response_code == 410) &&
462 update_type_ == UPGRADE_ATTEMPT) { 458 update_type_ == UPGRADE_ATTEMPT) {
463 service_->storage()->MakeGroupObsolete(group_, this); // async 459 service_->storage()->MakeGroupObsolete(group_, this); // async
464 } else { 460 } else {
465 std::string message; 461 const char* kFormatString = "Manifest fetch failed (%d) %s";
466 if (!is_valid_response_code) { 462 std::string message = base::StringPrintf(kFormatString, response_code,
467 const char* kFormatString = "Manifest fetch failed (%d) %s"; 463 manifest_url_.spec().c_str());
468 message = base::StringPrintf(kFormatString, response_code,
469 manifest_url_.spec().c_str());
470 } else {
471 DCHECK(!is_valid_mime_type);
472 const char* kFormatString = "Invalid manifest mime type (%s) %s";
473 message = base::StringPrintf(kFormatString, mime_type.c_str(),
474 manifest_url_.spec().c_str());
475 }
476 HandleCacheFailure(message); 464 HandleCacheFailure(message);
477 } 465 }
478 } 466 }
479 467
480 void AppCacheUpdateJob::OnGroupMadeObsolete(AppCacheGroup* group, 468 void AppCacheUpdateJob::OnGroupMadeObsolete(AppCacheGroup* group,
481 bool success) { 469 bool success) {
482 DCHECK(master_entry_fetches_.empty()); 470 DCHECK(master_entry_fetches_.empty());
483 CancelAllMasterEntryFetches("The cache has been made obsolete, " 471 CancelAllMasterEntryFetches("The cache has been made obsolete, "
484 "the manifest file returned 404 or 410"); 472 "the manifest file returned 404 or 410");
485 if (success) { 473 if (success) {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 862 }
875 } 863 }
876 864
877 void AppCacheUpdateJob::BuildUrlFileList(const Manifest& manifest) { 865 void AppCacheUpdateJob::BuildUrlFileList(const Manifest& manifest) {
878 for (base::hash_set<std::string>::const_iterator it = 866 for (base::hash_set<std::string>::const_iterator it =
879 manifest.explicit_urls.begin(); 867 manifest.explicit_urls.begin();
880 it != manifest.explicit_urls.end(); ++it) { 868 it != manifest.explicit_urls.end(); ++it) {
881 AddUrlToFileList(GURL(*it), AppCacheEntry::EXPLICIT); 869 AddUrlToFileList(GURL(*it), AppCacheEntry::EXPLICIT);
882 } 870 }
883 871
872 // TODO(michaeln): Add resources from intercept namepsaces too.
873 // http://code.google.com/p/chromium/issues/detail?id=101565
874
884 const std::vector<FallbackNamespace>& fallbacks = 875 const std::vector<FallbackNamespace>& fallbacks =
885 manifest.fallback_namespaces; 876 manifest.fallback_namespaces;
886 for (std::vector<FallbackNamespace>::const_iterator it = fallbacks.begin(); 877 for (std::vector<FallbackNamespace>::const_iterator it = fallbacks.begin();
887 it != fallbacks.end(); ++it) { 878 it != fallbacks.end(); ++it) {
888 AddUrlToFileList(it->second, AppCacheEntry::FALLBACK); 879 AddUrlToFileList(it->second, AppCacheEntry::FALLBACK);
889 } 880 }
890 881
891 // Add all master entries from newest complete cache. 882 // Add all master entries from newest complete cache.
892 if (update_type_ == UPGRADE_ATTEMPT) { 883 if (update_type_ == UPGRADE_ATTEMPT) {
893 const AppCache::EntryMap& entries = 884 const AppCache::EntryMap& entries =
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 1316
1326 // Break the connection with the group so the group cannot call delete 1317 // Break the connection with the group so the group cannot call delete
1327 // on this object after we've posted a task to delete ourselves. 1318 // on this object after we've posted a task to delete ourselves.
1328 group_->SetUpdateStatus(AppCacheGroup::IDLE); 1319 group_->SetUpdateStatus(AppCacheGroup::IDLE);
1329 group_ = NULL; 1320 group_ = NULL;
1330 1321
1331 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1322 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1332 } 1323 }
1333 1324
1334 } // namespace appcache 1325 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_interfaces.cc ('k') | webkit/appcache/appcache_update_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698