summaryrefslogtreecommitdiffstats
path: root/components/web_cache
diff options
context:
space:
mode:
authorlazyboy <lazyboy@chromium.org>2015-03-27 16:38:55 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-27 23:39:52 +0000
commitcbff2a79e3aafa333159dbc467efcb8a5dc124f7 (patch)
tree781c2947da061e226bfc914b08c9d045475bca0f /components/web_cache
parentb2512c2807be33d2956bb2d4ed5dfda7979a8a14 (diff)
downloadchromium_src-cbff2a79e3aafa333159dbc467efcb8a5dc124f7.zip
chromium_src-cbff2a79e3aafa333159dbc467efcb8a5dc124f7.tar.gz
chromium_src-cbff2a79e3aafa333159dbc467efcb8a5dc124f7.tar.bz2
<webview> Implement clear http cache API.
HTTP cache clearing methods have been refactored into a separate class: StoragePartitionBrowsingDataRemover in http://crrev.com/1033013003/ One method was exposed in WebCacheManager so we can clear renderer/ cache for a given render process. <webview> already has a set of data it can clear, this CL adds "cache" to that set, similar to chrome.browsingData API. BUG=406437 Test=Load a <webview> in a chrome app, e.g. the browser sample app: https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/webview-samples/browser Open inspector for the webview: from chrome://inspect, switch to Apps, and inspect the tab that says "Google" under "Browser sample". Switch to network tab in that inspector so you can monitor http requests. Visit some page in the <webview>, for my test case, I visited http://www.google.ca Now look at the network tab for image requests (cause it should be much simpler), e.g. nav_logo_195.png Reload the page couple of times, observer the status code for the image request, it should say 304 OK. Now open the app's inspector: Same as above, but inspect "Browser sample" instead. Call <webview> clear cache api from its console: document.querySelector('webview').clearData( {since: 1}, {cache: true}, function() { window.console.log('clear complete'); }) Expect "clear complete" message to show in app's console. Now reload the page one more time and check the same image's request, it should say 200 OK instead of 304. Review URL: https://codereview.chromium.org/1021073002 Cr-Commit-Position: refs/heads/master@{#322678}
Diffstat (limited to 'components/web_cache')
-rw-r--r--components/web_cache/browser/web_cache_manager.cc6
-rw-r--r--components/web_cache/browser/web_cache_manager.h3
2 files changed, 9 insertions, 0 deletions
diff --git a/components/web_cache/browser/web_cache_manager.cc b/components/web_cache/browser/web_cache_manager.cc
index 4acd209..92aca63 100644
--- a/components/web_cache/browser/web_cache_manager.cc
+++ b/components/web_cache/browser/web_cache_manager.cc
@@ -324,6 +324,12 @@ void WebCacheManager::EnactStrategy(const AllocationStrategy& strategy) {
}
}
+void WebCacheManager::ClearCacheForProcess(int render_process_id) {
+ std::set<int> renderers;
+ renderers.insert(render_process_id);
+ ClearRendererCache(renderers, INSTANTLY);
+}
+
void WebCacheManager::ClearRendererCache(
const std::set<int>& renderers,
WebCacheManager::ClearCacheOccasion occasion) {
diff --git a/components/web_cache/browser/web_cache_manager.h b/components/web_cache/browser/web_cache_manager.h
index d3ad0a1..0d2d3ff 100644
--- a/components/web_cache/browser/web_cache_manager.h
+++ b/components/web_cache/browser/web_cache_manager.h
@@ -86,6 +86,9 @@ class WebCacheManager : public content::NotificationObserver {
// Clears all in-memory caches.
void ClearCache();
+ // Instantly clears renderer cache for a process.
+ void ClearCacheForProcess(int process_id);
+
// Clears all in-memory caches when a tab is reloaded or the user navigates
// to a different website.
void ClearCacheOnNavigation();