diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 18:32:58 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 18:32:58 +0000 |
commit | 49837a1cc3f5c7779a7482480d466577b65281f4 (patch) | |
tree | 850942eb9babdbd651e4b45892c012e185585379 /webkit/appcache/web_application_cache_host_impl.cc | |
parent | 3d7409b276eda72842e106fc7feb5d59464887f5 (diff) | |
download | chromium_src-49837a1cc3f5c7779a7482480d466577b65281f4.zip chromium_src-49837a1cc3f5c7779a7482480d466577b65281f4.tar.gz chromium_src-49837a1cc3f5c7779a7482480d466577b65281f4.tar.bz2 |
Minor AppCache mods
* Add some more logging to the console window for when a cache is first created and when a master entry is added.
* Relocate the code that generates the log message for when a document is loaded from an appcache to the browser process.
* Use a Singleton<T> instead of a static global for an IDMap<T> used in child processes.
* Call the recently added webkit API for reporting progress events.
BUG=39370,13685
TEST=some existing automated tests apply, manual tests for the console logging
Review URL: http://codereview.chromium.org/2877005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/web_application_cache_host_impl.cc')
-rw-r--r-- | webkit/appcache/web_application_cache_host_impl.cc | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/webkit/appcache/web_application_cache_host_impl.cc b/webkit/appcache/web_application_cache_host_impl.cc index 15ef1db..8e7d37d 100644 --- a/webkit/appcache/web_application_cache_host_impl.cc +++ b/webkit/appcache/web_application_cache_host_impl.cc @@ -7,6 +7,7 @@ #include "base/compiler_specific.h" #include "base/id_map.h" #include "base/string_util.h" +#include "base/singleton.h" #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" @@ -23,10 +24,14 @@ using WebKit::WebURLResponse; namespace appcache { -static IDMap<WebApplicationCacheHostImpl> all_hosts; +typedef IDMap<WebApplicationCacheHostImpl> HostsMap; + +static HostsMap* all_hosts() { + return Singleton<HostsMap>::get(); +} WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) { - return all_hosts.Lookup(id); + return all_hosts()->Lookup(id); } WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromFrame( @@ -45,7 +50,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( AppCacheBackend* backend) : client_(client), backend_(backend), - ALLOW_THIS_IN_INITIALIZER_LIST(host_id_(all_hosts.Add(this))), + ALLOW_THIS_IN_INITIALIZER_LIST(host_id_(all_hosts()->Add(this))), has_status_(false), status_(UNCACHED), has_cached_status_(false), @@ -60,7 +65,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() { backend_->UnregisterHost(host_id_); - all_hosts.Remove(host_id_); + all_hosts()->Remove(host_id_); } void WebApplicationCacheHostImpl::OnCacheSelected(int64 selected_cache_id, @@ -85,11 +90,7 @@ void WebApplicationCacheHostImpl::OnEventRaised(appcache::EventID event_id) { void WebApplicationCacheHostImpl::OnProgressEventRaised( const GURL& url, int num_total, int num_complete) { - // TODO(michaeln): Widen the webkit api to accept the additional data. - // Also send the 'final' event once webkit layout tests have been updated. - // See https://bugs.webkit.org/show_bug.cgi?id=37602 - if (num_complete < num_total) - client_->notifyEventListener(WebApplicationCacheHost::ProgressEvent); + client_->notifyProgressEventListener(url, num_total, num_complete); } void WebApplicationCacheHostImpl::willStartMainResourceRequest( @@ -106,9 +107,6 @@ 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; @@ -121,9 +119,6 @@ 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,14 +232,4 @@ 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 |