summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_interfaces.cc
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 01:05:09 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 01:05:09 +0000
commit7e8e3dd7b1633874650f8de9a818aca8cb594f5b (patch)
tree5a973e64a1b5ca1a243744e2a9aa4a336a699985 /webkit/appcache/appcache_interfaces.cc
parent8b2034f851b1b41c2ec6539c057b63c92ef7289c (diff)
downloadchromium_src-7e8e3dd7b1633874650f8de9a818aca8cb594f5b.zip
chromium_src-7e8e3dd7b1633874650f8de9a818aca8cb594f5b.tar.gz
chromium_src-7e8e3dd7b1633874650f8de9a818aca8cb594f5b.tar.bz2
Check for supported schemes and examine request methods at key points. We support http, https, and file (dbg only) URLs for now.
* Added IsSchemeSupported, IsMethodSupported and IsMethodAndSchemeSupported helpers, and string constants. * Check for supported schemes and methods during cache selection and during request interception. Must be GET for cache selectino, GET or HEAD for request interception. * Renamed some data members in WebApplicationCacheHostImpl to more closely match naming elsewhere. * Added AppCacheHost::Observer to make life easier. (I like the observer model, and even noticed that the chrome code base has a multi-threaded version too (ala Gears)... nice :) * Switched to using the observer model in AppCacheRequestDispatcher instead of a WeakPtr. One of the observable methods is OnDestructionImminent(host). * Added gyp dependency on the net library BUG=none TEST=none Review URL: http://codereview.chromium.org/205017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26537 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_interfaces.cc')
-rw-r--r--webkit/appcache/appcache_interfaces.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc
index bd73879..1b7681f 100644
--- a/webkit/appcache/appcache_interfaces.cc
+++ b/webkit/appcache/appcache_interfaces.cc
@@ -3,15 +3,39 @@
// found in the LICENSE file.
#include "webkit/appcache/appcache_interfaces.h"
+
+#include "googleurl/src/gurl.h"
+#include "net/url_request/url_request.h"
#include "webkit/api/public/WebApplicationCacheHost.h"
using WebKit::WebApplicationCacheHost;
namespace appcache {
+const char kHttpScheme[] = "http";
+const char kHttpsScheme[] = "https";
+const char kHttpGETMethod[] = "GET";
+const char kHttpHEADMethod[] = "HEAD";
+
+bool IsSchemeSupported(const GURL& url) {
+ bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme);
+#ifndef NDEBUG
+ supported |= url.SchemeIsFile();
+#endif
+ return supported;
+}
+
+bool IsMethodSupported(const std::string& method) {
+ return (method == kHttpGETMethod) || (method == kHttpHEADMethod);
+}
+
+bool IsSchemeAndMethodSupported(const URLRequest* request) {
+ return IsSchemeSupported(request->url()) &&
+ IsMethodSupported(request->method());
+}
+
// Ensure that enum values never get out of sync with the
// ones declared for use within the WebKit api
-
COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached ==
(int)UNCACHED, Uncached);
COMPILE_ASSERT((int)WebApplicationCacheHost::Idle ==