diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 00:46:02 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 00:46:02 +0000 |
commit | df4cd1577cbd126d827a72cb0a15dcbe38a62a8b (patch) | |
tree | cdefa81e8266d3198ad9716824addc802a35b6a7 /webkit/appcache | |
parent | 2febbc7bc136af7212814e3495c135ec9fa98345 (diff) | |
download | chromium_src-df4cd1577cbd126d827a72cb0a15dcbe38a62a8b.zip chromium_src-df4cd1577cbd126d827a72cb0a15dcbe38a62a8b.tar.gz chromium_src-df4cd1577cbd126d827a72cb0a15dcbe38a62a8b.tar.bz2 |
AppCache: Output some information to the javascript console.
BUG=13685
TEST=manual
Review URL: http://codereview.chromium.org/2805030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50796 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
-rw-r--r-- | webkit/appcache/appcache_interfaces.cc | 10 | ||||
-rw-r--r-- | webkit/appcache/appcache_interfaces.h | 1 | ||||
-rw-r--r-- | webkit/appcache/web_application_cache_host_impl.cc | 22 | ||||
-rw-r--r-- | webkit/appcache/web_application_cache_host_impl.h | 4 |
4 files changed, 30 insertions, 7 deletions
diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc index b70cadf..a818bb9 100644 --- a/webkit/appcache/appcache_interfaces.cc +++ b/webkit/appcache/appcache_interfaces.cc @@ -7,8 +7,10 @@ #include "googleurl/src/gurl.h" #include "net/url_request/url_request.h" #include "third_party/WebKit/WebKit/chromium/public/WebApplicationCacheHost.h" +#include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" using WebKit::WebApplicationCacheHost; +using WebKit::WebConsoleMessage; namespace appcache { @@ -74,5 +76,13 @@ COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == (int)CACHED_EVENT, CachedEvent); COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == (int)OBSOLETE_EVENT, ObsoleteEvent); +COMPILE_ASSERT((int)WebConsoleMessage::LevelTip == + (int)LOG_TIP, LevelTip); +COMPILE_ASSERT((int)WebConsoleMessage::LevelLog == + (int)LOG_INFO, LevelLog); +COMPILE_ASSERT((int)WebConsoleMessage::LevelWarning == + (int)LOG_WARNING, LevelWarning); +COMPILE_ASSERT((int)WebConsoleMessage::LevelError == + (int)LOG_ERROR, LevelError); } // namespace diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h index a57ba67..b2a954e 100644 --- a/webkit/appcache/appcache_interfaces.h +++ b/webkit/appcache/appcache_interfaces.h @@ -45,6 +45,7 @@ enum EventID { }; enum LogLevel { + LOG_TIP, LOG_INFO, LOG_WARNING, LOG_ERROR, diff --git a/webkit/appcache/web_application_cache_host_impl.cc b/webkit/appcache/web_application_cache_host_impl.cc index 0f1258d..15ef1db 100644 --- a/webkit/appcache/web_application_cache_host_impl.cc +++ b/webkit/appcache/web_application_cache_host_impl.cc @@ -92,12 +92,6 @@ void WebApplicationCacheHostImpl::OnProgressEventRaised( client_->notifyEventListener(WebApplicationCacheHost::ProgressEvent); } -void WebApplicationCacheHostImpl::OnLogMessage( - LogLevel log_level, const std::string& message) { - // TODO(michaeln): Widen the webkit api with this addition. - // client_->notifyLogMessage(log_level, message); -} - void WebApplicationCacheHostImpl::willStartMainResourceRequest( WebURLRequest& request) { request.setAppCacheHostID(host_id_); @@ -112,6 +106,9 @@ void WebApplicationCacheHostImpl::willStartSubResourceRequest( } void WebApplicationCacheHostImpl::selectCacheWithoutManifest() { + if (document_response_.appCacheID() != kNoCacheId) + LogLoadedFromCacheMessage(); + // Reset any previous status values we've received from the backend // since we're now selecting a new cache. has_status_ = false; @@ -124,6 +121,9 @@ void WebApplicationCacheHostImpl::selectCacheWithoutManifest() { bool WebApplicationCacheHostImpl::selectCacheWithManifest( const WebURL& manifest_url) { + if (document_response_.appCacheID() != kNoCacheId) + LogLoadedFromCacheMessage(); + // Reset any previous status values we've received from the backend // since we're now selecting a new cache. has_status_ = false; @@ -237,4 +237,14 @@ bool WebApplicationCacheHostImpl::swapCache() { return backend_->SwapCache(host_id_); } +void WebApplicationCacheHostImpl::LogLoadedFromCacheMessage() { + DCHECK(!document_response_.appCacheManifestURL().isEmpty()); + GURL manifest_url = document_response_.appCacheManifestURL(); + std::string message = StringPrintf( + "Document %s was loaded from appcache %s", + document_url_.spec().c_str(), + manifest_url.spec().c_str()); + OnLogMessage(LOG_INFO, message); +} + } // appcache namespace diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h index 6f19b0d..9990c2c 100644 --- a/webkit/appcache/web_application_cache_host_impl.h +++ b/webkit/appcache/web_application_cache_host_impl.h @@ -36,7 +36,7 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost { void OnStatusChanged(appcache::Status); void OnEventRaised(appcache::EventID); void OnProgressEventRaised(const GURL& url, int num_total, int num_complete); - void OnLogMessage(LogLevel log_level, const std::string& message); + virtual void OnLogMessage(LogLevel log_level, const std::string& message) {} virtual void OnContentBlocked() {} // WebApplicationCacheHost methods @@ -58,6 +58,8 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost { NO }; + void LogLoadedFromCacheMessage(); + WebKit::WebApplicationCacheHostClient* client_; AppCacheBackend* backend_; int host_id_; |