Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: content/browser/appcache/manifest_parser.cc

Issue 344493002: Move all remaining appcache-related code to content namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This is a port of ManifestParser.cc from WebKit/WebCore/loader/appcache. 5 // This is a port of ManifestParser.cc from WebKit/WebCore/loader/appcache.
6 6
7 /* 7 /*
8 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 8 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 11 matching lines...) Expand all
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #include "webkit/browser/appcache/manifest_parser.h" 32 #include "content/browser/appcache/manifest_parser.h"
33 33
34 #include "base/command_line.h" 34 #include "base/command_line.h"
35 #include "base/i18n/icu_string_conversions.h" 35 #include "base/i18n/icu_string_conversions.h"
36 #include "base/logging.h" 36 #include "base/logging.h"
37 #include "base/strings/utf_string_conversions.h" 37 #include "base/strings/utf_string_conversions.h"
38 #include "url/gurl.h" 38 #include "url/gurl.h"
39 39
40 namespace appcache { 40 namespace content {
41 41
42 namespace { 42 namespace {
43 43
44 // Helper function used to identify 'isPattern' annotations. 44 // Helper function used to identify 'isPattern' annotations.
45 bool HasPatternMatchingAnnotation(const wchar_t* line_p, 45 bool HasPatternMatchingAnnotation(const wchar_t* line_p,
46 const wchar_t* line_end) { 46 const wchar_t* line_end) {
47 // Skip whitespace separating the resource url from the annotation. 47 // Skip whitespace separating the resource url from the annotation.
48 // Note: trailing whitespace has already been trimmed from the line. 48 // Note: trailing whitespace has already been trimmed from the line.
49 while (line_p < line_end && (*line_p == '\t' || *line_p == ' ')) 49 while (line_p < line_end && (*line_p == '\t' || *line_p == ' '))
50 ++line_p; 50 ++line_p;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // Per the spec, EXPLICIT cross-origin HTTS resources should be 212 // Per the spec, EXPLICIT cross-origin HTTS resources should be
213 // ignored here. We've opted for a milder constraint and allow 213 // ignored here. We've opted for a milder constraint and allow
214 // caching unless the resource has a "no-store" header. That 214 // caching unless the resource has a "no-store" header. That
215 // condition is enforced in AppCacheUpdateJob. 215 // condition is enforced in AppCacheUpdateJob.
216 216
217 if (mode == EXPLICIT) { 217 if (mode == EXPLICIT) {
218 manifest.explicit_urls.insert(url.spec()); 218 manifest.explicit_urls.insert(url.spec());
219 } else { 219 } else {
220 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end); 220 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end);
221 manifest.online_whitelist_namespaces.push_back( 221 manifest.online_whitelist_namespaces.push_back(
222 Namespace(APPCACHE_NETWORK_NAMESPACE, url, GURL(), is_pattern)); 222 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, url, GURL(),
223 is_pattern));
223 } 224 }
224 } else if (mode == INTERCEPT) { 225 } else if (mode == INTERCEPT) {
225 if (parse_mode != PARSE_MANIFEST_ALLOWING_INTERCEPTS) { 226 if (parse_mode != PARSE_MANIFEST_ALLOWING_INTERCEPTS) {
226 manifest.did_ignore_intercept_namespaces = true; 227 manifest.did_ignore_intercept_namespaces = true;
227 continue; 228 continue;
228 } 229 }
229 230
230 // Lines of the form, 231 // Lines of the form,
231 // <urlnamespace> <intercept_type> <targeturl> 232 // <urlnamespace> <intercept_type> <targeturl>
232 const wchar_t* line_p = line.c_str(); 233 const wchar_t* line_p = line.c_str();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (target_url.has_ref()) { 298 if (target_url.has_ref()) {
298 GURL::Replacements replacements; 299 GURL::Replacements replacements;
299 replacements.ClearRef(); 300 replacements.ClearRef();
300 target_url = target_url.ReplaceComponents(replacements); 301 target_url = target_url.ReplaceComponents(replacements);
301 } 302 }
302 if (manifest_url.GetOrigin() != target_url.GetOrigin()) 303 if (manifest_url.GetOrigin() != target_url.GetOrigin())
303 continue; 304 continue;
304 305
305 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end); 306 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end);
306 manifest.intercept_namespaces.push_back( 307 manifest.intercept_namespaces.push_back(
307 Namespace(APPCACHE_INTERCEPT_NAMESPACE, namespace_url, 308 AppCacheNamespace(APPCACHE_INTERCEPT_NAMESPACE, namespace_url,
308 target_url, is_pattern, verb == EXECUTE)); 309 target_url, is_pattern, verb == EXECUTE));
309 } else if (mode == FALLBACK) { 310 } else if (mode == FALLBACK) {
310 const wchar_t* line_p = line.c_str(); 311 const wchar_t* line_p = line.c_str();
311 const wchar_t* line_end = line_p + line.length(); 312 const wchar_t* line_end = line_p + line.length();
312 313
313 // Look for whitespace separating the two URLs 314 // Look for whitespace separating the two URLs
314 while (line_p < line_end && *line_p != '\t' && *line_p != ' ') 315 while (line_p < line_end && *line_p != '\t' && *line_p != ' ')
315 ++line_p; 316 ++line_p;
316 317
317 if (line_p == line_end) { 318 if (line_p == line_end) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // as the manifest's URL. 362 // as the manifest's URL.
362 if (manifest_url.GetOrigin() != fallback_url.GetOrigin()) { 363 if (manifest_url.GetOrigin() != fallback_url.GetOrigin()) {
363 continue; 364 continue;
364 } 365 }
365 366
366 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end); 367 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end);
367 368
368 // Store regardless of duplicate namespace URL. Only first match 369 // Store regardless of duplicate namespace URL. Only first match
369 // will ever be used. 370 // will ever be used.
370 manifest.fallback_namespaces.push_back( 371 manifest.fallback_namespaces.push_back(
371 Namespace(APPCACHE_FALLBACK_NAMESPACE, namespace_url, 372 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, namespace_url,
372 fallback_url, is_pattern)); 373 fallback_url, is_pattern));
373 } else { 374 } else {
374 NOTREACHED(); 375 NOTREACHED();
375 } 376 }
376 } 377 }
377 378
378 return true; 379 return true;
379 } 380 }
380 381
381 } // namespace appcache 382 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698