summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 20:04:48 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 20:04:48 +0000
commitdb41b844f92a7a4a01644bff013e297691f4a8e4 (patch)
treed9c6a1c8284d4aeb8c0892b512c286a14c94f4f4
parent05adb233720bd22661f602bf2bde0285df22db95 (diff)
downloadchromium_src-db41b844f92a7a4a01644bff013e297691f4a8e4.zip
chromium_src-db41b844f92a7a4a01644bff013e297691f4a8e4.tar.gz
chromium_src-db41b844f92a7a4a01644bff013e297691f4a8e4.tar.bz2
Add pieces needed by upcoming memory purge implementation:
* Get/set object cache disabled state * Add accessor for CrossOriginPreflightResultCache BUG=23400 TEST=none Review URL: http://codereview.chromium.org/257057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28299 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/api/public/WebCache.h10
-rw-r--r--webkit/api/public/WebCrossOriginPreflightResultCache.h50
-rw-r--r--webkit/api/public/WebFontCache.h10
-rw-r--r--webkit/api/src/WebCache.cpp22
-rw-r--r--webkit/api/src/WebCrossOriginPreflightResultCache.cpp43
-rw-r--r--webkit/api/src/WebFontCache.cpp8
-rw-r--r--webkit/webkit.gyp2
7 files changed, 130 insertions, 15 deletions
diff --git a/webkit/api/public/WebCache.h b/webkit/api/public/WebCache.h
index 71b45fd..2f47bcd 100644
--- a/webkit/api/public/WebCache.h
+++ b/webkit/api/public/WebCache.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -70,6 +70,10 @@ namespace WebKit {
size_t maxDeadCapacity,
size_t capacity);
+ // Clears the cache (as much as possible; some resources may not be
+ // cleared if they are actively referenced).
+ WEBKIT_API static void clear();
+
// Gets the usage statistics from the resource cache.
WEBKIT_API static void getUsageStats(UsageStats*);
diff --git a/webkit/api/public/WebCrossOriginPreflightResultCache.h b/webkit/api/public/WebCrossOriginPreflightResultCache.h
new file mode 100644
index 0000000..a28f8e4
--- /dev/null
+++ b/webkit/api/public/WebCrossOriginPreflightResultCache.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebCrossOriginPreflightResultCache_h
+#define WebCrossOriginPreflightResultCache_h
+
+#include "WebCommon.h"
+
+namespace WebKit {
+
+ // An interface to configure WebKit's cross-origin preflight result cache.
+ class WebCrossOriginPreflightResultCache {
+ public:
+ // Clears the cache.
+ WEBKIT_API static void clear();
+
+ private:
+ WebCrossOriginPreflightResultCache(); // Not intended to be instanced.
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/public/WebFontCache.h b/webkit/api/public/WebFontCache.h
index e9e4399..b5877c2 100644
--- a/webkit/api/public/WebFontCache.h
+++ b/webkit/api/public/WebFontCache.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -44,8 +44,8 @@ namespace WebKit {
// Returns the number of inactive items in the font data cache.
WEBKIT_API static size_t inactiveFontDataCount();
- // Invalidates and purges all data held in the font data cache.
- WEBKIT_API static void invalidate();
+ // Clears the cache.
+ WEBKIT_API static void clear();
private:
WebFontCache(); // Not intended to be instanced.
diff --git a/webkit/api/src/WebCache.cpp b/webkit/api/src/WebCache.cpp
index 7d8164e..9d03a4d 100644
--- a/webkit/api/src/WebCache.cpp
+++ b/webkit/api/src/WebCache.cpp
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -63,6 +63,22 @@ void WebCache::setCapacities(
static_cast<unsigned int>(capacity));
}
+void WebCache::clear()
+{
+ Cache* cache = WebCore::cache();
+ if (cache && !cache->disabled()) {
+ // NOTE: I think using setDisabled() instead of setCapacities() will
+ // remove from the cache items that won't actually be freed from memory
+ // (due to other live references to them), so it just results in wasting
+ // time later and not saving memory compared to the below technique.
+ unsigned minDeadCapacity = cache->m_minDeadCapacity;
+ unsigned maxDeadCapacity = cache->m_maxDeadCapacity;
+ unsigned capacity = cache->m_capacity;
+ cache->setCapacities(0, 0, 0); // Will prune the cache.
+ cache->setCapacities(minDeadCapacity, maxDeadCapacity, capacity);
+ }
+}
+
void WebCache::getUsageStats(UsageStats* result)
{
ASSERT(result);
diff --git a/webkit/api/src/WebCrossOriginPreflightResultCache.cpp b/webkit/api/src/WebCrossOriginPreflightResultCache.cpp
new file mode 100644
index 0000000..719316d
--- /dev/null
+++ b/webkit/api/src/WebCrossOriginPreflightResultCache.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebCrossOriginPreflightResultCache.h"
+
+#include "CrossOriginPreflightResultCache.h"
+
+namespace WebKit {
+
+void WebCrossOriginPreflightResultCache::clear()
+{
+ WebCore::CrossOriginPreflightResultCache::shared().empty();
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/WebFontCache.cpp b/webkit/api/src/WebFontCache.cpp
index 65ed56d..52358ec 100644
--- a/webkit/api/src/WebFontCache.cpp
+++ b/webkit/api/src/WebFontCache.cpp
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -50,7 +50,7 @@ size_t WebFontCache::inactiveFontDataCount()
}
// static
-void WebFontCache::invalidate()
+void WebFontCache::clear()
{
fontCache()->invalidate();
}
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 64d3820..e46d49c 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -88,6 +88,7 @@
'api/public/WebCommon.h',
'api/public/WebCompositionCommand.h',
'api/public/WebConsoleMessage.h',
+ 'api/public/WebCrossOriginPreflightResultCache.h',
'api/public/WebCString.h',
'api/public/WebCursorInfo.h',
'api/public/WebData.h',
@@ -186,6 +187,7 @@
'api/src/WebBindings.cpp',
'api/src/WebCache.cpp',
'api/src/WebColor.cpp',
+ 'api/src/WebCrossOriginPreflightResultCache.cpp',
'api/src/WebCString.cpp',
'api/src/WebCursorInfo.cpp',
'api/src/WebData.cpp',