summaryrefslogtreecommitdiffstats
path: root/webkit/appcache
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 18:32:58 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 18:32:58 +0000
commit49837a1cc3f5c7779a7482480d466577b65281f4 (patch)
tree850942eb9babdbd651e4b45892c012e185585379 /webkit/appcache
parent3d7409b276eda72842e106fc7feb5d59464887f5 (diff)
downloadchromium_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')
-rw-r--r--webkit/appcache/appcache_host.cc15
-rw-r--r--webkit/appcache/web_application_cache_host_impl.cc35
-rw-r--r--webkit/appcache/web_application_cache_host_impl.h2
3 files changed, 24 insertions, 28 deletions
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc
index 6d0336b..8553324 100644
--- a/webkit/appcache/appcache_host.cc
+++ b/webkit/appcache/appcache_host.cc
@@ -5,6 +5,7 @@
#include "webkit/appcache/appcache_host.h"
#include "base/logging.h"
+#include "base/string_util.h"
#include "webkit/appcache/appcache.h"
#include "webkit/appcache/appcache_backend_impl.h"
#include "webkit/appcache/appcache_request_handler.h"
@@ -313,8 +314,14 @@ void AppCacheHost::FinishCacheSelection(
// context being navigated.
DCHECK(cache->owning_group());
DCHECK(new_master_entry_url_.is_empty());
- AssociateCache(cache);
AppCacheGroup* owing_group = cache->owning_group();
+ const char* kFormatString =
+ "Document was loaded from appcache with manifest %s";
+ frontend_->OnLogMessage(
+ host_id_, LOG_INFO,
+ StringPrintf(
+ kFormatString, owing_group->manifest_url().spec().c_str()));
+ AssociateCache(cache);
if (!owing_group->is_obsolete() && !owing_group->is_being_deleted()) {
owing_group->StartUpdateWithHost(this);
ObserveGroupBeingUpdated(owing_group);
@@ -327,6 +334,12 @@ void AppCacheHost::FinishCacheSelection(
// resource from which document was loaded as the new master resourse.
DCHECK(!group->is_obsolete());
DCHECK(new_master_entry_url_.is_valid());
+ const char* kFormatString = group->HasCache() ?
+ "Adding master entry to appcache with manifest %s" :
+ "Creating appcache with manifest %s";
+ frontend_->OnLogMessage(
+ host_id_, LOG_INFO,
+ StringPrintf(kFormatString, group->manifest_url().spec().c_str()));
AssociateCache(NULL); // The UpdateJob may produce one for us later.
group->StartUpdateWithNewMasterEntry(this, new_master_entry_url_);
ObserveGroupBeingUpdated(group);
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
diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h
index 9990c2c..84aa4d3 100644
--- a/webkit/appcache/web_application_cache_host_impl.h
+++ b/webkit/appcache/web_application_cache_host_impl.h
@@ -58,8 +58,6 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost {
NO
};
- void LogLoadedFromCacheMessage();
-
WebKit::WebApplicationCacheHostClient* client_;
AppCacheBackend* backend_;
int host_id_;