summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/appcache/appcache_dispatcher_host.cc16
-rw-r--r--chrome/browser/appcache/appcache_dispatcher_host.h4
-rw-r--r--chrome/browser/appcache/appcache_frontend_proxy.cc6
-rw-r--r--chrome/browser/appcache/appcache_frontend_proxy.h4
-rw-r--r--chrome/browser/browsing_data_appcache_helper.cc9
-rw-r--r--chrome/common/appcache/appcache_backend_proxy.cc5
-rw-r--r--chrome/common/appcache/appcache_backend_proxy.h3
-rw-r--r--chrome/common/appcache/appcache_dispatcher.cc6
-rw-r--r--chrome/common/appcache/appcache_dispatcher.h4
-rw-r--r--chrome/common/render_messages.h84
-rw-r--r--chrome/common/render_messages_internal.h11
-rw-r--r--chrome/renderer/renderer_webapplicationcachehost_impl.cc4
-rw-r--r--chrome/renderer/renderer_webapplicationcachehost_impl.h3
-rw-r--r--webkit/appcache/appcache.cc7
-rw-r--r--webkit/appcache/appcache.h5
-rw-r--r--webkit/appcache/appcache_backend_impl.cc9
-rw-r--r--webkit/appcache/appcache_backend_impl.h2
-rw-r--r--webkit/appcache/appcache_frontend_impl.cc6
-rw-r--r--webkit/appcache/appcache_frontend_impl.h5
-rw-r--r--webkit/appcache/appcache_group.h4
-rw-r--r--webkit/appcache/appcache_group_unittest.cc11
-rw-r--r--webkit/appcache/appcache_host.cc36
-rw-r--r--webkit/appcache/appcache_host.h3
-rw-r--r--webkit/appcache/appcache_host_unittest.cc8
-rw-r--r--webkit/appcache/appcache_interfaces.h35
-rw-r--r--webkit/appcache/appcache_request_handler_unittest.cc4
-rw-r--r--webkit/appcache/appcache_service.h24
-rw-r--r--webkit/appcache/appcache_storage_impl.cc21
-rw-r--r--webkit/appcache/appcache_update_job_unittest.cc4
-rw-r--r--webkit/appcache/web_application_cache_host_impl.cc41
-rw-r--r--webkit/appcache/web_application_cache_host_impl.h10
-rw-r--r--webkit/tools/test_shell/simple_appcache_system.cc25
32 files changed, 319 insertions, 100 deletions
diff --git a/chrome/browser/appcache/appcache_dispatcher_host.cc b/chrome/browser/appcache/appcache_dispatcher_host.cc
index b3a7bb0..e37784f 100644
--- a/chrome/browser/appcache/appcache_dispatcher_host.cc
+++ b/chrome/browser/appcache/appcache_dispatcher_host.cc
@@ -61,6 +61,7 @@ bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg,
IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok)
IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost);
IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost);
+ IPC_MESSAGE_HANDLER(AppCacheMsg_GetResourceList, OnGetResourceList);
IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache);
IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForWorker,
OnSelectCacheForWorker);
@@ -102,8 +103,7 @@ void AppCacheDispatcherHost::OnSelectCache(
ReceivedBadMessage(AppCacheMsg_SelectCache::ID);
}
} else {
- frontend_proxy_.OnCacheSelected(
- host_id, appcache::kNoCacheId, appcache::UNCACHED);
+ frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo());
}
}
@@ -115,8 +115,7 @@ void AppCacheDispatcherHost::OnSelectCacheForWorker(
ReceivedBadMessage(AppCacheMsg_SelectCacheForWorker::ID);
}
} else {
- frontend_proxy_.OnCacheSelected(
- host_id, appcache::kNoCacheId, appcache::UNCACHED);
+ frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo());
}
}
@@ -126,8 +125,7 @@ void AppCacheDispatcherHost::OnSelectCacheForSharedWorker(
if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id))
ReceivedBadMessage(AppCacheMsg_SelectCacheForSharedWorker::ID);
} else {
- frontend_proxy_.OnCacheSelected(
- host_id, appcache::kNoCacheId, appcache::UNCACHED);
+ frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo());
}
}
@@ -142,6 +140,12 @@ void AppCacheDispatcherHost::OnMarkAsForeignEntry(
}
}
+void AppCacheDispatcherHost::OnGetResourceList(
+ int host_id, std::vector<appcache::AppCacheResourceInfo>* params) {
+ if (appcache_service_.get())
+ backend_impl_.GetResourceList(host_id, params);
+}
+
void AppCacheDispatcherHost::OnGetStatus(int host_id,
IPC::Message* reply_msg) {
if (pending_reply_msg_.get()) {
diff --git a/chrome/browser/appcache/appcache_dispatcher_host.h b/chrome/browser/appcache/appcache_dispatcher_host.h
index ceb0528..c54784c 100644
--- a/chrome/browser/appcache/appcache_dispatcher_host.h
+++ b/chrome/browser/appcache/appcache_dispatcher_host.h
@@ -59,7 +59,9 @@ class AppCacheDispatcherHost {
void OnGetStatus(int host_id, IPC::Message* reply_msg);
void OnStartUpdate(int host_id, IPC::Message* reply_msg);
void OnSwapCache(int host_id, IPC::Message* reply_msg);
-
+ void OnGetResourceList(
+ int host_id,
+ std::vector<appcache::AppCacheResourceInfo>* resource_infos);
void GetStatusCallback(appcache::Status status, void* param);
void StartUpdateCallback(bool result, void* param);
void SwapCacheCallback(bool result, void* param);
diff --git a/chrome/browser/appcache/appcache_frontend_proxy.cc b/chrome/browser/appcache/appcache_frontend_proxy.cc
index 78ec85d..0a80424 100644
--- a/chrome/browser/appcache/appcache_frontend_proxy.cc
+++ b/chrome/browser/appcache/appcache_frontend_proxy.cc
@@ -6,9 +6,9 @@
#include "chrome/common/render_messages.h"
-void AppCacheFrontendProxy::OnCacheSelected(int host_id, int64 cache_id ,
- appcache::Status status) {
- sender_->Send(new AppCacheMsg_CacheSelected(host_id, cache_id, status));
+void AppCacheFrontendProxy::OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) {
+ sender_->Send(new AppCacheMsg_CacheSelected(host_id, info));
}
void AppCacheFrontendProxy::OnStatusChanged(const std::vector<int>& host_ids,
diff --git a/chrome/browser/appcache/appcache_frontend_proxy.h b/chrome/browser/appcache/appcache_frontend_proxy.h
index c23eeca9..2d3775c 100644
--- a/chrome/browser/appcache/appcache_frontend_proxy.h
+++ b/chrome/browser/appcache/appcache_frontend_proxy.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_APPCACHE_APPCACHE_FRONTEND_PROXY_H_
#pragma once
+#include <string>
#include <vector>
#include "ipc/ipc_message.h"
@@ -19,8 +20,7 @@ class AppCacheFrontendProxy : public appcache::AppCacheFrontend {
IPC::Message::Sender* sender() const { return sender_; }
// AppCacheFrontend methods
- virtual void OnCacheSelected(int host_id, int64 cache_id ,
- appcache::Status);
+ virtual void OnCacheSelected(int host_id, const appcache::AppCacheInfo& info);
virtual void OnStatusChanged(const std::vector<int>& host_ids,
appcache::Status status);
virtual void OnEventRaised(const std::vector<int>& host_ids,
diff --git a/chrome/browser/browsing_data_appcache_helper.cc b/chrome/browser/browsing_data_appcache_helper.cc
index 3ce7106..2e58c6b 100644
--- a/chrome/browser/browsing_data_appcache_helper.cc
+++ b/chrome/browser/browsing_data_appcache_helper.cc
@@ -118,12 +118,9 @@ void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) {
return;
}
- appcache_infos_.push_back(
- appcache::AppCacheInfo(manifest_url,
- 0,
- base::Time(),
- base::Time(),
- base::Time()));
+ appcache::AppCacheInfo info;
+ info.manifest_url = manifest_url;
+ appcache_infos_.push_back(info);
}
void CannedBrowsingDataAppCacheHelper::Reset() {
diff --git a/chrome/common/appcache/appcache_backend_proxy.cc b/chrome/common/appcache/appcache_backend_proxy.cc
index e1776db..16e0ff4 100644
--- a/chrome/common/appcache/appcache_backend_proxy.cc
+++ b/chrome/common/appcache/appcache_backend_proxy.cc
@@ -63,3 +63,8 @@ bool AppCacheBackendProxy::SwapCache(int host_id) {
sender_->Send(new AppCacheMsg_SwapCache(host_id, &result));
return result;
}
+
+void AppCacheBackendProxy::GetResourceList(
+ int host_id, std::vector<appcache::AppCacheResourceInfo>* resource_infos) {
+ sender_->Send(new AppCacheMsg_GetResourceList(host_id, resource_infos));
+}
diff --git a/chrome/common/appcache/appcache_backend_proxy.h b/chrome/common/appcache/appcache_backend_proxy.h
index 9c237d8..8d9de2b 100644
--- a/chrome/common/appcache/appcache_backend_proxy.h
+++ b/chrome/common/appcache/appcache_backend_proxy.h
@@ -36,6 +36,9 @@ class AppCacheBackendProxy : public appcache::AppCacheBackend {
virtual appcache::Status GetStatus(int host_id);
virtual bool StartUpdate(int host_id);
virtual bool SwapCache(int host_id);
+ virtual void GetResourceList(
+ int host_id,
+ std::vector<appcache::AppCacheResourceInfo>* resource_infos);
private:
IPC::Message::Sender* sender_;
diff --git a/chrome/common/appcache/appcache_dispatcher.cc b/chrome/common/appcache/appcache_dispatcher.cc
index 6cf40cc..b32b48e 100644
--- a/chrome/common/appcache/appcache_dispatcher.cc
+++ b/chrome/common/appcache/appcache_dispatcher.cc
@@ -22,9 +22,9 @@ bool AppCacheDispatcher::OnMessageReceived(const IPC::Message& msg) {
return handled;
}
-void AppCacheDispatcher::OnCacheSelected(int host_id, int64 cache_id,
- appcache::Status status) {
- frontend_impl_.OnCacheSelected(host_id, cache_id, status);
+void AppCacheDispatcher::OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) {
+ frontend_impl_.OnCacheSelected(host_id, info);
}
void AppCacheDispatcher::OnStatusChanged(const std::vector<int>& host_ids,
diff --git a/chrome/common/appcache/appcache_dispatcher.h b/chrome/common/appcache/appcache_dispatcher.h
index 2e17349..f099183 100644
--- a/chrome/common/appcache/appcache_dispatcher.h
+++ b/chrome/common/appcache/appcache_dispatcher.h
@@ -6,6 +6,7 @@
#define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_H_
#pragma once
+#include <string>
#include <vector>
#include "chrome/common/appcache/appcache_backend_proxy.h"
#include "ipc/ipc_message.h"
@@ -26,8 +27,7 @@ class AppCacheDispatcher {
private:
// Ipc message handlers
- void OnCacheSelected(int host_id, int64 cache_id,
- appcache::Status status);
+ void OnCacheSelected(int host_id, const appcache::AppCacheInfo& info);
void OnStatusChanged(const std::vector<int>& host_ids,
appcache::Status status);
void OnEventRaised(const std::vector<int>& host_ids,
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index c94ac98..50b18c0 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -3144,6 +3144,90 @@ struct ParamTraits<ViewMsg_ExtensionExtentsUpdated_Params> {
}
};
+template<>
+struct ParamTraits<appcache::AppCacheResourceInfo> {
+ typedef appcache::AppCacheResourceInfo param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.url);
+ WriteParam(m, p.size);
+ WriteParam(m, p.is_manifest);
+ WriteParam(m, p.is_master);
+ WriteParam(m, p.is_fallback);
+ WriteParam(m, p.is_foreign);
+ WriteParam(m, p.is_explicit);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return ReadParam(m, iter, &p->url) &&
+ ReadParam(m, iter, &p->size) &&
+ ReadParam(m, iter, &p->is_manifest) &&
+ ReadParam(m, iter, &p->is_master) &&
+ ReadParam(m, iter, &p->is_fallback) &&
+ ReadParam(m, iter, &p->is_foreign) &&
+ ReadParam(m, iter, &p->is_explicit);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.url, l);
+ l->append(L", ");
+ LogParam(p.size, l);
+ l->append(L", ");
+ LogParam(p.is_manifest, l);
+ l->append(L", ");
+ LogParam(p.is_master, l);
+ l->append(L", ");
+ LogParam(p.is_fallback, l);
+ l->append(L", ");
+ LogParam(p.is_foreign, l);
+ l->append(L", ");
+ LogParam(p.is_explicit, l);
+ l->append(L")");
+ }
+};
+
+template <>
+ struct ParamTraits<appcache::AppCacheInfo> {
+ typedef appcache::AppCacheInfo param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, p.manifest_url);
+ WriteParam(m, p.creation_time);
+ WriteParam(m, p.last_update_time);
+ WriteParam(m, p.last_access_time);
+ WriteParam(m, p.cache_id);
+ WriteParam(m, p.status);
+ WriteParam(m, p.size);
+ WriteParam(m, p.is_complete);
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ return ReadParam(m, iter, &p->manifest_url) &&
+ ReadParam(m, iter, &p->creation_time) &&
+ ReadParam(m, iter, &p->last_update_time) &&
+ ReadParam(m, iter, &p->last_access_time) &&
+ ReadParam(m, iter, &p->cache_id) &&
+ ReadParam(m, iter, &p->status) &&
+ ReadParam(m, iter, &p->size) &&
+ ReadParam(m, iter, &p->is_complete);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ LogParam(p.manifest_url, l);
+ l->append(L", ");
+ LogParam(p.creation_time, l);
+ l->append(L", ");
+ LogParam(p.last_update_time, l);
+ l->append(L", ");
+ LogParam(p.last_access_time, l);
+ l->append(L", ");
+ LogParam(p.cache_id, l);
+ l->append(L", ");
+ LogParam(p.status, l);
+ l->append(L", ");
+ LogParam(p.size, l);
+ l->append(L")");
+ LogParam(p.is_complete, l);
+ l->append(L", ");
+ }
+ };
+
template <>
struct ParamTraits<WindowContainerType> {
typedef WindowContainerType param_type;
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 7e60194..89b4d57 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -601,10 +601,9 @@ IPC_BEGIN_MESSAGES(View)
// Notifies the renderer of the appcache that has been selected for a
// a particular host. This is sent in reply to AppCacheMsg_SelectCache.
- IPC_MESSAGE_CONTROL3(AppCacheMsg_CacheSelected,
+ IPC_MESSAGE_CONTROL2(AppCacheMsg_CacheSelected,
int /* host_id */,
- int64 /* appcache_id */,
- appcache::Status)
+ appcache::AppCacheInfo)
// Notifies the renderer of an AppCache status change.
IPC_MESSAGE_CONTROL2(AppCacheMsg_StatusChanged,
@@ -1868,6 +1867,12 @@ IPC_BEGIN_MESSAGES(ViewHost)
int /* host_id */,
bool /* success */)
+ // Gets resource list from appcache synchronously.
+ IPC_SYNC_MESSAGE_CONTROL1_1(AppCacheMsg_GetResourceList,
+ int /* host_id in*/,
+ std::vector<appcache::AppCacheResourceInfo>
+ /* resources out */)
+
// Returns the resizer box location in the window this widget is embedded.
// Important for Mac OS X, but not Win or Linux.
IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_GetRootWindowResizerRect,
diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.cc b/chrome/renderer/renderer_webapplicationcachehost_impl.cc
index f5bad0c..88540df 100644
--- a/chrome/renderer/renderer_webapplicationcachehost_impl.cc
+++ b/chrome/renderer/renderer_webapplicationcachehost_impl.cc
@@ -43,10 +43,10 @@ void RendererWebApplicationCacheHostImpl::OnContentBlocked(
}
void RendererWebApplicationCacheHostImpl::OnCacheSelected(
- int64 selected_cache_id, appcache::Status status) {
+ const appcache::AppCacheInfo& info) {
// TODO(jochen): Send a ViewHostMsg_AppCacheAccessed to the browser once this
// methods gets the manifest url passed.
- WebApplicationCacheHostImpl::OnCacheSelected(selected_cache_id, status);
+ WebApplicationCacheHostImpl::OnCacheSelected(info);
}
RenderView* RendererWebApplicationCacheHostImpl::GetRenderView() {
diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.h b/chrome/renderer/renderer_webapplicationcachehost_impl.h
index 6405317..c8454e5 100644
--- a/chrome/renderer/renderer_webapplicationcachehost_impl.h
+++ b/chrome/renderer/renderer_webapplicationcachehost_impl.h
@@ -22,8 +22,7 @@ class RendererWebApplicationCacheHostImpl
virtual void OnLogMessage(appcache::LogLevel log_level,
const std::string& message);
virtual void OnContentBlocked(const GURL& manifest_url);
- virtual void OnCacheSelected(int64 selected_cache_id,
- appcache::Status status);
+ virtual void OnCacheSelected(const appcache::AppCacheInfo& info);
private:
RenderView* GetRenderView();
diff --git a/webkit/appcache/appcache.cc b/webkit/appcache/appcache.cc
index e1819d4..4bc7294 100644
--- a/webkit/appcache/appcache.cc
+++ b/webkit/appcache/appcache.cc
@@ -21,6 +21,7 @@ AppCache::AppCache(AppCacheService *service, int64 cache_id)
owning_group_(NULL),
online_whitelist_all_(false),
is_complete_(false),
+ cache_size_(0),
service_(service) {
service_->storage()->working_set()->AddCache(this);
}
@@ -51,7 +52,8 @@ bool AppCache::AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry) {
// Entry already exists. Merge the types of the new and existing entries.
if (!ret.second)
ret.first->second.add_types(entry.types());
-
+ else
+ cache_size_ += entry.response_size(); // New entry. Add to cache size.
return ret.second;
}
@@ -61,12 +63,10 @@ AppCacheEntry* AppCache::GetEntry(const GURL& url) {
}
namespace {
-
bool SortByLength(
const FallbackNamespace& lhs, const FallbackNamespace& rhs) {
return lhs.first.spec().length() > rhs.first.spec().length();
}
-
}
void AppCache::InitializeWithManifest(Manifest* manifest) {
@@ -162,7 +162,6 @@ void AppCache::ToDatabaseRecords(
}
}
-
bool AppCache::FindResponseForRequest(const GURL& url,
AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry,
GURL* found_fallback_namespace, bool* found_network_namespace) {
diff --git a/webkit/appcache/appcache.h b/webkit/appcache/appcache.h
index 325c5113..eab23bb 100644
--- a/webkit/appcache/appcache.h
+++ b/webkit/appcache/appcache.h
@@ -72,6 +72,9 @@ class AppCache : public base::RefCounted<AppCache> {
}
base::Time update_time() const { return update_time_; }
+
+ int64 cache_size() const { return cache_size_; }
+
void set_update_time(base::Time ticks) { update_time_ = ticks; }
// Initializes the cache with information in the manifest.
@@ -135,6 +138,8 @@ class AppCache : public base::RefCounted<AppCache> {
// when this cache was last updated
base::Time update_time_;
+ int64 cache_size_;
+
// to notify service when cache is deleted
AppCacheService* service_;
diff --git a/webkit/appcache/appcache_backend_impl.cc b/webkit/appcache/appcache_backend_impl.cc
index 6bacc26..e077a33 100644
--- a/webkit/appcache/appcache_backend_impl.cc
+++ b/webkit/appcache/appcache_backend_impl.cc
@@ -123,4 +123,13 @@ bool AppCacheBackendImpl::SwapCacheWithCallback(
return true;
}
+void AppCacheBackendImpl::GetResourceList(
+ int host_id, std::vector<appcache::AppCacheResourceInfo>* resource_infos) {
+ AppCacheHost* host = GetHost(host_id);
+ if (!host)
+ return;
+
+ host->GetResourceList(resource_infos);
+}
+
} // namespace appcache
diff --git a/webkit/appcache/appcache_backend_impl.h b/webkit/appcache/appcache_backend_impl.h
index b957ae3..d299641 100644
--- a/webkit/appcache/appcache_backend_impl.h
+++ b/webkit/appcache/appcache_backend_impl.h
@@ -32,6 +32,8 @@ class AppCacheBackendImpl {
const GURL& document_url,
const int64 cache_document_was_loaded_from,
const GURL& manifest_url);
+ void GetResourceList(
+ int host_id, std::vector<AppCacheResourceInfo>* resource_infos);
bool SelectCacheForWorker(int host_id, int parent_process_id,
int parent_host_id);
bool SelectCacheForSharedWorker(int host_id, int64 appcache_id);
diff --git a/webkit/appcache/appcache_frontend_impl.cc b/webkit/appcache/appcache_frontend_impl.cc
index 812ae69..f39cbd2 100644
--- a/webkit/appcache/appcache_frontend_impl.cc
+++ b/webkit/appcache/appcache_frontend_impl.cc
@@ -14,11 +14,11 @@ inline WebApplicationCacheHostImpl* GetHost(int id) {
return WebApplicationCacheHostImpl::FromId(id);
}
-void AppCacheFrontendImpl::OnCacheSelected(int host_id, int64 cache_id ,
- Status status) {
+void AppCacheFrontendImpl::OnCacheSelected(
+ int host_id, const AppCacheInfo& info) {
WebApplicationCacheHostImpl* host = GetHost(host_id);
if (host)
- host->OnCacheSelected(cache_id, status);
+ host->OnCacheSelected(info);
}
void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids,
diff --git a/webkit/appcache/appcache_frontend_impl.h b/webkit/appcache/appcache_frontend_impl.h
index e05dcb7..159cbec 100644
--- a/webkit/appcache/appcache_frontend_impl.h
+++ b/webkit/appcache/appcache_frontend_impl.h
@@ -5,6 +5,7 @@
#ifndef WEBKIT_APPCACHE_APPCACHE_FRONTEND_IMPL_H_
#define WEBKIT_APPCACHE_APPCACHE_FRONTEND_IMPL_H_
+#include <string>
#include <vector>
#include "webkit/appcache/appcache_interfaces.h"
@@ -12,8 +13,8 @@ namespace appcache {
class AppCacheFrontendImpl : public AppCacheFrontend {
public:
- virtual void OnCacheSelected(int host_id, int64 cache_id,
- Status status);
+ virtual void OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info);
virtual void OnStatusChanged(const std::vector<int>& host_ids,
Status status);
virtual void OnEventRaised(const std::vector<int>& host_ids,
diff --git a/webkit/appcache/appcache_group.h b/webkit/appcache/appcache_group.h
index a811337..efcec48 100644
--- a/webkit/appcache/appcache_group.h
+++ b/webkit/appcache/appcache_group.h
@@ -54,7 +54,8 @@ class AppCacheGroup : public base::RefCounted<AppCacheGroup> {
int64 group_id() const { return group_id_; }
const GURL& manifest_url() const { return manifest_url_; }
-
+ const base::Time& creation_time() const { return creation_time_; }
+ void set_creation_time(const base::Time& time) { creation_time_ = time; }
bool is_obsolete() const { return is_obsolete_; }
void set_obsolete(bool value) { is_obsolete_ = value; }
@@ -122,6 +123,7 @@ class AppCacheGroup : public base::RefCounted<AppCacheGroup> {
const int64 group_id_;
const GURL manifest_url_;
+ base::Time creation_time_;
UpdateStatus update_status_;
bool is_obsolete_;
bool is_being_deleted_;
diff --git a/webkit/appcache/appcache_group_unittest.cc b/webkit/appcache/appcache_group_unittest.cc
index 2c6ed14..128fbc7 100644
--- a/webkit/appcache/appcache_group_unittest.cc
+++ b/webkit/appcache/appcache_group_unittest.cc
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/appcache/appcache.h"
#include "webkit/appcache/appcache_group.h"
#include "webkit/appcache/appcache_host.h"
#include "webkit/appcache/mock_appcache_service.h"
#include "webkit/appcache/appcache_update_job.h"
+#include "webkit/appcache/appcache_interfaces.h"
namespace {
@@ -18,11 +21,11 @@ class TestAppCacheFrontend : public appcache::AppCacheFrontend {
last_status_(appcache::OBSOLETE) {
}
- virtual void OnCacheSelected(int host_id, int64 cache_id ,
- appcache::Status status) {
+ virtual void OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) {
last_host_id_ = host_id;
- last_cache_id_ = cache_id;
- last_status_ = status;
+ last_cache_id_ = info.cache_id;
+ last_status_ = info.status;
}
virtual void OnStatusChanged(const std::vector<int>& host_ids,
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc
index c4e8b62..66cf2a8 100644
--- a/webkit/appcache/appcache_host.cc
+++ b/webkit/appcache/appcache_host.cc
@@ -252,6 +252,25 @@ AppCacheRequestHandler* AppCacheHost::CreateRequestHandler(
return NULL;
}
+void AppCacheHost::GetResourceList(
+ std::vector<AppCacheResourceInfo>* resource_infos) {
+ if (associated_cache_.get() && associated_cache_->is_complete()) {
+ for (AppCache::EntryMap::const_iterator it =
+ associated_cache_->entries().begin();
+ it != associated_cache_->entries().end(); ++it) {
+ AppCacheResourceInfo info;
+ info.url = it->first;
+ info.is_master = it->second.IsMaster();
+ info.is_manifest = it->second.IsManifest();
+ info.is_fallback = it->second.IsFallback();
+ info.is_foreign = it->second.IsForeign();
+ info.is_explicit = it->second.IsExplicit();
+ info.size = it->second.response_size();
+ resource_infos->push_back(info);
+ }
+ }
+}
+
Status AppCacheHost::GetStatus() {
// 6.9.8 Application cache API
AppCache* cache = associated_cache();
@@ -417,12 +436,23 @@ void AppCacheHost::AssociateCache(AppCache* cache) {
associated_cache_ = cache;
SetSwappableCache(cache ? cache->owning_group() : NULL);
-
+ AppCacheInfo info;
if (cache) {
cache->AssociateHost(this);
- frontend_->OnCacheSelected(host_id_, cache->cache_id(), GetStatus());
+ info.cache_id = cache->cache_id();
+ info.status = GetStatus();
+ info.is_complete = cache->is_complete();
+ if (cache->is_complete()) {
+ // TODO(kkanetkar): Get manifest URL info for NULL owning_group().
+ info.manifest_url = cache->owning_group()->manifest_url();
+ info.last_update_time = cache->update_time();
+ info.creation_time = cache->owning_group()->creation_time();
+ info.size = cache->cache_size();
+ }
+ frontend_->OnCacheSelected(host_id_, info);
} else {
- frontend_->OnCacheSelected(host_id_, kNoCacheId, UNCACHED);
+ // No Cache.
+ frontend_->OnCacheSelected(host_id_, info);
}
}
diff --git a/webkit/appcache/appcache_host.h b/webkit/appcache/appcache_host.h
index 7701f95..ff87b5f 100644
--- a/webkit/appcache/appcache_host.h
+++ b/webkit/appcache/appcache_host.h
@@ -74,6 +74,9 @@ class AppCacheHost : public AppCacheStorage::Delegate,
AppCacheRequestHandler* CreateRequestHandler(
URLRequest* request, ResourceType::Type resource_type);
+ // Support for devtools inspecting appcache resources.
+ void GetResourceList(std::vector<AppCacheResourceInfo>* resource_infos);
+
// Establishes an association between this host and a cache. 'cache' may be
// NULL to break any existing association. Associations are established
// either thru the cache selection algorithm implemented (in this class),
diff --git a/webkit/appcache/appcache_host_unittest.cc b/webkit/appcache/appcache_host_unittest.cc
index 0671eb7..4f83928 100644
--- a/webkit/appcache/appcache_host_unittest.cc
+++ b/webkit/appcache/appcache_host_unittest.cc
@@ -34,11 +34,11 @@ class AppCacheHostTest : public testing::Test {
last_event_id_(appcache::OBSOLETE_EVENT) {
}
- virtual void OnCacheSelected(int host_id, int64 cache_id ,
- appcache::Status status) {
+ virtual void OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) {
last_host_id_ = host_id;
- last_cache_id_ = cache_id;
- last_status_ = status;
+ last_cache_id_ = info.cache_id;
+ last_status_ = info.status;
}
virtual void OnStatusChanged(const std::vector<int>& host_ids,
diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h
index 1956135..1dfd326 100644
--- a/webkit/appcache/appcache_interfaces.h
+++ b/webkit/appcache/appcache_interfaces.h
@@ -9,8 +9,9 @@
#include <vector>
#include "base/basictypes.h"
#include "base/file_path.h"
+#include "base/time.h"
+#include "googleurl/src/gurl.h"
-class GURL;
class URLRequest;
namespace appcache {
@@ -51,11 +52,37 @@ enum LogLevel {
LOG_ERROR,
};
+struct AppCacheInfo {
+ GURL manifest_url;
+ base::Time creation_time;
+ base::Time last_update_time;
+ base::Time last_access_time;
+ int64 cache_id;
+ Status status;
+ int64 size;
+ bool is_complete;
+ AppCacheInfo() : cache_id(kNoCacheId), status(UNCACHED),
+ size(0), is_complete(false) { }
+};
+
+typedef std::vector<AppCacheInfo> AppCacheInfoVector;
+
+// POD type to hold information about a single appcache resource.
+struct AppCacheResourceInfo {
+ GURL url;
+ int64 size;
+ bool is_master;
+ bool is_manifest;
+ bool is_fallback;
+ bool is_foreign;
+ bool is_explicit;
+};
+
// Interface used by backend (browser-process) to talk to frontend (renderer).
class AppCacheFrontend {
public:
- virtual void OnCacheSelected(int host_id, int64 cache_id ,
- Status status) = 0;
+ virtual void OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) = 0;
virtual void OnStatusChanged(const std::vector<int>& host_ids,
Status status) = 0;
virtual void OnEventRaised(const std::vector<int>& host_ids,
@@ -93,6 +120,8 @@ class AppCacheBackend {
virtual Status GetStatus(int host_id) = 0;
virtual bool StartUpdate(int host_id) = 0;
virtual bool SwapCache(int host_id) = 0;
+ virtual void GetResourceList(
+ int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0;
virtual ~AppCacheBackend() {}
};
diff --git a/webkit/appcache/appcache_request_handler_unittest.cc b/webkit/appcache/appcache_request_handler_unittest.cc
index a857be6..8d22a49 100644
--- a/webkit/appcache/appcache_request_handler_unittest.cc
+++ b/webkit/appcache/appcache_request_handler_unittest.cc
@@ -27,8 +27,8 @@ class AppCacheRequestHandlerTest : public testing::Test {
public:
class MockFrontend : public AppCacheFrontend {
public:
- virtual void OnCacheSelected(int host_id, int64 cache_id ,
- appcache::Status status) {}
+ virtual void OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) {}
virtual void OnStatusChanged(const std::vector<int>& host_ids,
appcache::Status status) {}
diff --git a/webkit/appcache/appcache_service.h b/webkit/appcache/appcache_service.h
index ac5aa4a..6ba04c8 100644
--- a/webkit/appcache/appcache_service.h
+++ b/webkit/appcache/appcache_service.h
@@ -15,6 +15,7 @@
#include "net/base/completion_callback.h"
#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
+#include "webkit/appcache/appcache_interfaces.h"
#include "webkit/appcache/appcache_storage.h"
class URLRequestContext;
@@ -28,29 +29,6 @@ namespace appcache {
class AppCacheBackendImpl;
class AppCachePolicy;
-// Structure that contains basic info about an appcache.
-struct AppCacheInfo {
- AppCacheInfo() {}
- AppCacheInfo(const GURL& manifest_url,
- int64 size,
- base::Time creation_time,
- base::Time last_access_time,
- base::Time last_update_time)
- : manifest_url(manifest_url),
- size(size),
- creation_time(creation_time),
- last_access_time(last_access_time),
- last_update_time(last_update_time) {
- }
- GURL manifest_url;
- int64 size;
- base::Time creation_time;
- base::Time last_access_time;
- base::Time last_update_time;
-};
-
-typedef std::vector<AppCacheInfo> AppCacheInfoVector;
-
// Refcounted container to avoid copying the collection in callbacks.
struct AppCacheInfoCollection
: public base::RefCountedThreadSafe<AppCacheInfoCollection> {
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc
index 265ff30..3f9ba1a 100644
--- a/webkit/appcache/appcache_storage_impl.cc
+++ b/webkit/appcache/appcache_storage_impl.cc
@@ -221,11 +221,15 @@ void AppCacheStorageImpl::GetAllInfoTask::Run() {
group != groups.end(); ++group) {
AppCacheDatabase::CacheRecord cache_record;
database_->FindCacheForGroup(group->group_id, &cache_record);
- infos.push_back(
- AppCacheInfo(
- group->manifest_url, cache_record.cache_size,
- group->creation_time, group->last_access_time,
- cache_record.update_time));
+ AppCacheInfo info;
+ info.manifest_url = group->manifest_url;
+ info.creation_time = group->creation_time;
+ info.size = cache_record.cache_size;
+ info.last_access_time = group->last_access_time;
+ info.last_update_time = cache_record.update_time;
+ info.cache_id = cache_record.cache_id;
+ info.is_complete = true;
+ infos.push_back(info);
}
}
}
@@ -282,6 +286,7 @@ void AppCacheStorageImpl::StoreOrLoadTask::CreateCacheAndGroupFromRecords(
(*group) = new AppCacheGroup(
storage_->service_, group_record_.manifest_url,
group_record_.group_id);
+ group->get()->set_creation_time(group_record_.creation_time);
group->get()->AddCache(cache->get());
}
DCHECK(group->get()->newest_complete_cache() == cache->get());
@@ -376,8 +381,7 @@ void AppCacheStorageImpl::GroupLoadTask::RunCompleted() {
CreateCacheAndGroupFromRecords(&cache, &group);
} else {
group = new AppCacheGroup(
- storage_->service_, manifest_url_,
- storage_->NewGroupId());
+ storage_->service_, manifest_url_, storage_->NewGroupId());
}
}
FOR_EACH_DELEGATE(delegates_, OnGroupLoaded(group, manifest_url_));
@@ -483,6 +487,7 @@ void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() {
void AppCacheStorageImpl::StoreGroupAndCacheTask::RunCompleted() {
if (success_) {
+ // TODO(kkanetkar): Add to creation time when that's enabled.
storage_->origins_with_groups_.insert(group_->manifest_url().GetOrigin());
if (cache_ != group_->newest_complete_cache()) {
cache_->set_complete(true);
@@ -536,13 +541,11 @@ class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask {
};
namespace {
-
bool SortByLength(
const AppCacheDatabase::FallbackNameSpaceRecord& lhs,
const AppCacheDatabase::FallbackNameSpaceRecord& rhs) {
return lhs.namespace_url.spec().length() > rhs.namespace_url.spec().length();
}
-
}
void AppCacheStorageImpl::FindMainResponseTask::Run() {
diff --git a/webkit/appcache/appcache_update_job_unittest.cc b/webkit/appcache/appcache_update_job_unittest.cc
index 0bcda2c..46dce34 100644
--- a/webkit/appcache/appcache_update_job_unittest.cc
+++ b/webkit/appcache/appcache_update_job_unittest.cc
@@ -167,8 +167,8 @@ class MockFrontend : public AppCacheFrontend {
start_update_trigger_(CHECKING_EVENT), update_(NULL) {
}
- virtual void OnCacheSelected(int host_id, int64 cache_id,
- Status status) {
+ virtual void OnCacheSelected(
+ int host_id, const appcache::AppCacheInfo& info) {
}
virtual void OnStatusChanged(const std::vector<int>& host_ids,
diff --git a/webkit/appcache/web_application_cache_host_impl.cc b/webkit/appcache/web_application_cache_host_impl.cc
index 042a06f..82f8eb3 100644
--- a/webkit/appcache/web_application_cache_host_impl.cc
+++ b/webkit/appcache/web_application_cache_host_impl.cc
@@ -21,6 +21,7 @@ using WebKit::WebFrame;
using WebKit::WebURLRequest;
using WebKit::WebURL;
using WebKit::WebURLResponse;
+using WebKit::WebVector;
namespace appcache {
@@ -87,10 +88,12 @@ WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() {
all_hosts()->Remove(host_id_);
}
-void WebApplicationCacheHostImpl::OnCacheSelected(int64 selected_cache_id,
- appcache::Status status) {
- status_ = status;
+void WebApplicationCacheHostImpl::OnCacheSelected(
+ const appcache::AppCacheInfo& info) {
+ status_ = info.status;
has_status_ = true;
+ cache_info_ = info;
+ client_->didChangeCacheAssociation();
}
void WebApplicationCacheHostImpl::OnStatusChanged(appcache::Status status) {
@@ -169,6 +172,38 @@ void WebApplicationCacheHostImpl::selectCacheWithoutManifest() {
GURL());
}
+void WebApplicationCacheHostImpl::getAssociatedCacheInfo(
+ WebApplicationCacheHost::CacheInfo* info) {
+ if (!cache_info_.is_complete)
+ return;
+ info->manifestURL = cache_info_.manifest_url;
+ info->creationTime = cache_info_.creation_time.ToDoubleT();
+ info->updateTime = cache_info_.last_update_time.ToDoubleT();
+ info->totalSize = cache_info_.size;
+}
+
+void WebApplicationCacheHostImpl::getResourceList(
+ WebVector<ResourceInfo>* resources) {
+ if (!cache_info_.is_complete)
+ return;
+ std::vector<AppCacheResourceInfo> resource_infos;
+ backend_->GetResourceList(host_id_, &resource_infos);
+
+ WebVector<ResourceInfo> web_resources(resource_infos.size());
+ // Convert resource_infos to WebKit API.
+ for (size_t i = 0; i < resource_infos.size(); ++i) {
+ web_resources[i].size = resource_infos[i].size;
+ web_resources[i].isMaster = resource_infos[i].is_master;
+ web_resources[i].isExplicit = resource_infos[i].is_explicit;
+ web_resources[i].isManifest = resource_infos[i].is_manifest;
+ web_resources[i].isForeign = resource_infos[i].is_foreign;
+ web_resources[i].isFallback = resource_infos[i].is_fallback;
+ web_resources[i].url = resource_infos[i].url;
+ }
+
+ resources->swap(web_resources);
+}
+
bool WebApplicationCacheHostImpl::selectCacheWithManifest(
const WebURL& manifest_url) {
// Reset any previous status values we've received from the backend
diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h
index f71398f..cdb812a 100644
--- a/webkit/appcache/web_application_cache_host_impl.h
+++ b/webkit/appcache/web_application_cache_host_impl.h
@@ -5,9 +5,12 @@
#ifndef WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
#define WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
+#include <string>
+#include "base/time.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebApplicationCacheHostClient.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "webkit/appcache/appcache_interfaces.h"
namespace WebKit {
@@ -32,14 +35,13 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost {
AppCacheBackend* backend() const { return backend_; }
WebKit::WebApplicationCacheHostClient* client() const { return client_; }
+ virtual void OnCacheSelected(const appcache::AppCacheInfo& info);
void OnStatusChanged(appcache::Status);
void OnEventRaised(appcache::EventID);
void OnProgressEventRaised(const GURL& url, int num_total, int num_complete);
void OnErrorEventRaised(const std::string& message);
virtual void OnLogMessage(LogLevel log_level, const std::string& message) {}
virtual void OnContentBlocked(const GURL& manifest_url) {}
- virtual void OnCacheSelected(int64 selected_cache_id,
- appcache::Status status);
// WebApplicationCacheHost methods
virtual void willStartMainResourceRequest(WebKit::WebURLRequest&);
@@ -52,6 +54,8 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost {
virtual WebKit::WebApplicationCacheHost::Status status();
virtual bool startUpdate();
virtual bool swapCache();
+ virtual void getResourceList(WebKit::WebVector<ResourceInfo>* resources);
+ virtual void getAssociatedCacheInfo(CacheInfo* info);
private:
enum IsNewMasterEntry {
@@ -72,9 +76,11 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost {
bool is_scheme_supported_;
bool is_get_method_;
IsNewMasterEntry is_new_master_entry_;
+ appcache::AppCacheInfo cache_info_;
GURL original_main_resource_url_; // Used to detect redirection.
};
} // namespace
#endif // WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
+
diff --git a/webkit/tools/test_shell/simple_appcache_system.cc b/webkit/tools/test_shell/simple_appcache_system.cc
index 9706f48..c23604a 100644
--- a/webkit/tools/test_shell/simple_appcache_system.cc
+++ b/webkit/tools/test_shell/simple_appcache_system.cc
@@ -59,16 +59,17 @@ class SimpleFrontendProxy
void clear_appcache_system() { system_ = NULL; }
- virtual void OnCacheSelected(int host_id, int64 cache_id ,
- appcache::Status status) {
+ virtual void OnCacheSelected(int host_id,
+ const appcache::AppCacheInfo& info) {
if (!system_)
return;
if (system_->is_io_thread())
system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
this, &SimpleFrontendProxy::OnCacheSelected,
- host_id, cache_id, status));
- else if (system_->is_ui_thread())
- system_->frontend_impl_.OnCacheSelected(host_id, cache_id, status);
+ host_id, info));
+ else if (system_->is_ui_thread()) {
+ system_->frontend_impl_.OnCacheSelected(host_id, info);
+ }
else
NOTREACHED();
}
@@ -213,6 +214,20 @@ class SimpleBackendProxy
}
}
+ virtual void GetResourceList(
+ int host_id,
+ std::vector<appcache::AppCacheResourceInfo>* resource_infos) {
+ if (system_->is_ui_thread()) {
+ system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &SimpleBackendProxy::GetResourceList,
+ host_id, resource_infos));
+ } else if (system_->is_io_thread()) {
+ system_->backend_impl_->GetResourceList(host_id, resource_infos);
+ } else {
+ NOTREACHED();
+ }
+ }
+
virtual void SelectCacheForWorker(
int host_id,
int parent_process_id,