A stab at fixing a crashing bug and a bandaid to prevent the crash if that stab is in the wrong place.

BUG=94620
Review URL: http://codereview.chromium.org/7835023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99814 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/webkit/appcache/appcache_request_handler.cc b/webkit/appcache/appcache_request_handler.cc
index a90d6d7..583df28 100644
--- a/webkit/appcache/appcache_request_handler.cc
+++ b/webkit/appcache/appcache_request_handler.cc
@@ -58,6 +58,7 @@
     if (job_->cache_entry_not_found())
       cache_entry_not_found_ = true;
     job_ = NULL;
+    storage()->CancelDelegateCallbacks(this);
     return NULL;
   }
 
@@ -218,12 +219,16 @@
     const GURL& fallback_url, const AppCacheEntry& fallback_entry,
     int64 cache_id, const GURL& manifest_url,
     bool was_blocked_by_policy) {
+  DCHECK(job_);
   DCHECK(host_);
   DCHECK(is_main_resource());
   DCHECK(!entry.IsForeign());
   DCHECK(!fallback_entry.IsForeign());
   DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id()));
 
+  if (!job_)
+    return;
+
   if (ResourceType::IsFrame(resource_type_)) {
     if (was_blocked_by_policy)
       host_->NotifyMainResourceBlocked(manifest_url);