| OLD | NEW | 
|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "webkit/appcache/appcache_interfaces.h" | 5 #include "webkit/appcache/appcache_interfaces.h" | 
|  | 6 | 
|  | 7 #include "googleurl/src/gurl.h" | 
|  | 8 #include "net/url_request/url_request.h" | 
| 6 #include "webkit/api/public/WebApplicationCacheHost.h" | 9 #include "webkit/api/public/WebApplicationCacheHost.h" | 
| 7 | 10 | 
| 8 using WebKit::WebApplicationCacheHost; | 11 using WebKit::WebApplicationCacheHost; | 
| 9 | 12 | 
| 10 namespace appcache { | 13 namespace appcache { | 
| 11 | 14 | 
|  | 15 const char kHttpScheme[] = "http"; | 
|  | 16 const char kHttpsScheme[] = "https"; | 
|  | 17 const char kHttpGETMethod[] = "GET"; | 
|  | 18 const char kHttpHEADMethod[] = "HEAD"; | 
|  | 19 | 
|  | 20 bool IsSchemeSupported(const GURL& url) { | 
|  | 21   bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme); | 
|  | 22 #ifndef NDEBUG | 
|  | 23   supported |= url.SchemeIsFile(); | 
|  | 24 #endif | 
|  | 25   return supported; | 
|  | 26 } | 
|  | 27 | 
|  | 28 bool IsMethodSupported(const std::string& method) { | 
|  | 29   return (method == kHttpGETMethod) || (method == kHttpHEADMethod); | 
|  | 30 } | 
|  | 31 | 
|  | 32 bool IsSchemeAndMethodSupported(const URLRequest* request) { | 
|  | 33   return IsSchemeSupported(request->url()) && | 
|  | 34          IsMethodSupported(request->method()); | 
|  | 35 } | 
|  | 36 | 
| 12 // Ensure that enum values never get out of sync with the | 37 // Ensure that enum values never get out of sync with the | 
| 13 // ones declared for use within the WebKit api | 38 // ones declared for use within the WebKit api | 
| 14 |  | 
| 15 COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached == | 39 COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached == | 
| 16                (int)UNCACHED, Uncached); | 40                (int)UNCACHED, Uncached); | 
| 17 COMPILE_ASSERT((int)WebApplicationCacheHost::Idle == | 41 COMPILE_ASSERT((int)WebApplicationCacheHost::Idle == | 
| 18                (int)IDLE, Idle); | 42                (int)IDLE, Idle); | 
| 19 COMPILE_ASSERT((int)WebApplicationCacheHost::Checking == | 43 COMPILE_ASSERT((int)WebApplicationCacheHost::Checking == | 
| 20                (int)CHECKING, Checking); | 44                (int)CHECKING, Checking); | 
| 21 COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading == | 45 COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading == | 
| 22                (int)DOWNLOADING, Downloading); | 46                (int)DOWNLOADING, Downloading); | 
| 23 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady == | 47 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady == | 
| 24                (int)UPDATE_READY, UpdateReady); | 48                (int)UPDATE_READY, UpdateReady); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 35 COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent == | 59 COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent == | 
| 36                (int)PROGRESS_EVENT, ProgressEvent); | 60                (int)PROGRESS_EVENT, ProgressEvent); | 
| 37 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent == | 61 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent == | 
| 38                (int)UPDATE_READY_EVENT, UpdateReadyEvent); | 62                (int)UPDATE_READY_EVENT, UpdateReadyEvent); | 
| 39 COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == | 63 COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == | 
| 40                (int)CACHED_EVENT, CachedEvent); | 64                (int)CACHED_EVENT, CachedEvent); | 
| 41 COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == | 65 COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == | 
| 42                (int)OBSOLETE_EVENT, ObsoleteEvent); | 66                (int)OBSOLETE_EVENT, ObsoleteEvent); | 
| 43 | 67 | 
| 44 }  // namespace | 68 }  // namespace | 
| OLD | NEW | 
|---|