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

Unified Diff: webkit/browser/appcache/appcache_update_job.cc

Issue 164933002: Expose details for appcache error events [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: webkit/browser/appcache/appcache_update_job.cc
diff --git a/webkit/browser/appcache/appcache_update_job.cc b/webkit/browser/appcache/appcache_update_job.cc
index 03bb909cf09e64bca4e879a469299410c2597c53..dbfd66c660a873e7e653e4a3cd8bcf061324674e 100644
--- a/webkit/browser/appcache/appcache_update_job.cc
+++ b/webkit/browser/appcache/appcache_update_job.cc
@@ -76,12 +76,16 @@ class HostNotifier {
}
}
- void SendErrorNotifications(const std::string& error_message) {
+ void SendErrorNotifications(const std::string& error_message,
+ appcache::ErrorReason reason,
+ const GURL& url,
+ int status) {
DCHECK(!error_message.empty());
for (NotifyHostMap::iterator it = hosts_to_notify.begin();
it != hosts_to_notify.end(); ++it) {
AppCacheFrontend* frontend = it->first;
- frontend->OnErrorEventRaised(it->second, error_message);
+ frontend->OnErrorEventRaised(
+ it->second, error_message, reason, url, status);
}
}
@@ -420,17 +424,20 @@ AppCacheResponseWriter* AppCacheUpdateJob::CreateResponseWriter() {
return writer;
}
-void AppCacheUpdateJob::HandleCacheFailure(
- const std::string& error_message,
- ResultType result) {
+void AppCacheUpdateJob::HandleCacheFailure(const std::string& error_message,
+ ErrorReason reason,
+ const GURL& resource_url,
+ int resource_status,
+ ResultType result) {
// 6.9.4 cache failure steps 2-8.
DCHECK(internal_state_ != CACHE_FAILURE);
DCHECK(!error_message.empty());
DCHECK(result != UPDATE_OK);
internal_state_ = CACHE_FAILURE;
CancelAllUrlFetches();
- CancelAllMasterEntryFetches(error_message);
- NotifyAllError(error_message);
+ CancelAllMasterEntryFetches(
+ error_message, reason, resource_url, resource_status);
+ NotifyAllError(error_message, reason, resource_url, resource_status);
DiscardInprogressCache();
internal_state_ = COMPLETED;
AppCacheHistograms::CountUpdateJobResult(
@@ -498,15 +505,23 @@ void AppCacheUpdateJob::HandleManifestFetchCompleted(
const char* kFormatString = "Manifest fetch failed (%d) %s";
std::string message = FormatUrlErrorMessage(
kFormatString, manifest_url_, fetcher->result(), response_code);
- HandleCacheFailure(message, fetcher->result());
+ HandleCacheFailure(message,
+ ERROR_MANIFEST_FETCH,
+ manifest_url_,
+ response_code,
+ fetcher->result());
}
}
void AppCacheUpdateJob::OnGroupMadeObsolete(AppCacheGroup* group,
bool success) {
DCHECK(master_entry_fetches_.empty());
- CancelAllMasterEntryFetches("The cache has been made obsolete, "
- "the manifest file returned 404 or 410");
+ CancelAllMasterEntryFetches(
+ "The cache has been made obsolete, "
+ "the manifest file returned 404 or 410",
+ ERROR_MANIFEST_OBSOLETE,
+ GURL(),
+ 0);
if (success) {
DCHECK(group->is_obsolete());
NotifyAllAssociatedHosts(OBSOLETE_EVENT);
@@ -514,7 +529,11 @@ void AppCacheUpdateJob::OnGroupMadeObsolete(AppCacheGroup* group,
MaybeCompleteUpdate();
} else {
// Treat failure to mark group obsolete as a cache failure.
- HandleCacheFailure("Failed to mark the cache as obsolete", DB_ERROR);
+ HandleCacheFailure("Failed to mark the cache as obsolete",
+ ERROR_INTERNAL,
+ GURL(),
+ 0,
+ DB_ERROR);
}
}
@@ -537,7 +556,8 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) {
const char* kFormatString = "Failed to parse manifest %s";
const std::string message = base::StringPrintf(kFormatString,
manifest_url_.spec().c_str());
- HandleCacheFailure(message, MANIFEST_ERROR);
+ HandleCacheFailure(
+ message, ERROR_MANIFEST_INVALID, manifest_url_, 0, MANIFEST_ERROR);
michaeln 2014/03/01 00:20:02 maybe use an empty GURL() here too?
jsbell 2014/03/01 00:53:07 Will do.
VLOG(1) << message;
return;
}
@@ -611,7 +631,13 @@ void AppCacheUpdateJob::HandleUrlFetchCompleted(URLFetcher* fetcher) {
const char* kFormatString = "Resource fetch failed (%d) %s";
std::string message = FormatUrlErrorMessage(
kFormatString, url, fetcher->result(), response_code);
- HandleCacheFailure(message, fetcher->result());
+ ResultType result = fetcher->result();
+ HandleCacheFailure(
+ message,
+ result == DISKCACHE_ERROR ? ERROR_INTERNAL : ERROR_RESOURCE_FETCH,
michaeln 2014/03/01 00:20:02 This looks reasonable to me, there is something th
jsbell 2014/03/01 00:53:07 D'oh, right. I'll fix. BTW, I'm making the minima
+ url,
+ response_code,
+ result);
return;
}
} else if (response_code == 404 || response_code == 410) {
@@ -696,7 +722,8 @@ void AppCacheUpdateJob::HandleMasterEntryFetchCompleted(
const char* kFormatString = "Manifest fetch failed (%d) %s";
std::string message = FormatUrlErrorMessage(
kFormatString, request->url(), fetcher->result(), response_code);
- host_notifier.SendErrorNotifications(message);
+ host_notifier.SendErrorNotifications(
+ message, ERROR_MANIFEST_FETCH, request->url(), response_code);
// In downloading case, update result is different if all master entries
// failed vs. only some failing.
@@ -707,7 +734,11 @@ void AppCacheUpdateJob::HandleMasterEntryFetchCompleted(
// Section 6.9.4, step 22.3.
if (update_type_ == CACHE_ATTEMPT && pending_master_entries_.empty()) {
- HandleCacheFailure(message, fetcher->result());
+ HandleCacheFailure(message,
+ ERROR_MANIFEST_FETCH,
+ request->url(),
+ response_code,
+ fetcher->result());
return;
}
}
@@ -749,12 +780,20 @@ void AppCacheUpdateJob::HandleManifestRefetchCompleted(
<< " response code: " << response_code;
ScheduleUpdateRetry(kRerunDelayMs);
if (response_code == 200) {
- HandleCacheFailure("Manifest changed during update", MANIFEST_ERROR);
+ HandleCacheFailure("Manifest changed during update",
+ ERROR_MANIFEST_CHANGED,
+ manifest_url_,
+ response_code,
+ MANIFEST_ERROR);
} else {
const char* kFormatString = "Manifest re-fetch failed (%d) %s";
std::string message = FormatUrlErrorMessage(
kFormatString, manifest_url_, fetcher->result(), response_code);
- HandleCacheFailure(message, fetcher->result());
+ HandleCacheFailure(message,
+ ERROR_MANIFEST_FETCH,
+ manifest_url_,
+ response_code,
+ fetcher->result());
}
}
}
@@ -770,6 +809,9 @@ void AppCacheUpdateJob::OnManifestInfoWriteComplete(int result) {
base::Unretained(this)));
} else {
HandleCacheFailure("Failed to write the manifest headers to storage",
+ ERROR_INTERNAL,
+ GURL(),
+ 0,
DISKCACHE_ERROR);
}
}
@@ -784,6 +826,9 @@ void AppCacheUpdateJob::OnManifestDataWriteComplete(int result) {
StoreGroupAndCache();
} else {
HandleCacheFailure("Failed to write the manifest data to storage",
+ ERROR_INTERNAL,
+ GURL(),
+ 0,
DISKCACHE_ERROR);
}
}
@@ -825,7 +870,12 @@ void AppCacheUpdateJob::OnGroupAndNewestCacheStored(AppCacheGroup* group,
message.append(", would exceed quota");
result = QUOTA_ERROR;
}
- HandleCacheFailure(message, result);
+ HandleCacheFailure(
+ message,
+ would_exceed_quota ? ERROR_QUOTA_EXCEEDED : ERROR_INTERNAL,
+ GURL(),
+ 0,
+ result);
}
}
@@ -853,10 +903,14 @@ void AppCacheUpdateJob::NotifyAllFinalProgress() {
NotifyAllProgress(GURL());
}
-void AppCacheUpdateJob::NotifyAllError(const std::string& error_message) {
+void AppCacheUpdateJob::NotifyAllError(const std::string& error_message,
+ ErrorReason reason,
+ const GURL& resource_url,
+ int resource_status) {
HostNotifier host_notifier;
AddAllAssociatedHostsToNotifier(&host_notifier);
- host_notifier.SendErrorNotifications(error_message);
+ host_notifier.SendErrorNotifications(
+ error_message, reason, resource_url, resource_status);
}
void AppCacheUpdateJob::AddAllAssociatedHostsToNotifier(
@@ -911,6 +965,9 @@ void AppCacheUpdateJob::CheckIfManifestChanged() {
// Use a local variable because service_ is reset in HandleCacheFailure.
AppCacheService* service = service_;
HandleCacheFailure("Manifest entry not found in existing cache",
+ ERROR_INTERNAL,
+ GURL(),
+ 0,
DB_ERROR);
AppCacheHistograms::AddMissingManifestEntrySample();
service->DeleteAppCacheGroup(manifest_url_, net::CompletionCallback());
@@ -1152,7 +1209,10 @@ void AppCacheUpdateJob::FetchMasterEntries() {
}
void AppCacheUpdateJob::CancelAllMasterEntryFetches(
- const std::string& error_message) {
+ const std::string& error_message,
+ ErrorReason reason,
+ const GURL& resource_url,
+ int resource_status) {
// For now, cancel all in-progress fetches for master entries and pretend
// all master entries fetches have completed.
// TODO(jennb): Delete this when update no longer fetches master entries
@@ -1188,7 +1248,8 @@ void AppCacheUpdateJob::CancelAllMasterEntryFetches(
master_entries_to_fetch_.erase(master_entries_to_fetch_.begin());
}
- host_notifier.SendErrorNotifications(error_message);
+ host_notifier.SendErrorNotifications(
+ error_message, reason, resource_url, resource_status);
}
bool AppCacheUpdateJob::MaybeLoadFromNewestCache(const GURL& url,
« no previous file with comments | « webkit/browser/appcache/appcache_update_job.h ('k') | webkit/browser/appcache/appcache_update_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698