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

Side by Side Diff: webkit/appcache/manifest_parser.cc

Issue 13219005: Replace string16 with base::string16 in src/webkit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 Manifest::~Manifest() {} 51 Manifest::~Manifest() {}
52 52
53 bool ParseManifest(const GURL& manifest_url, const char* data, int length, 53 bool ParseManifest(const GURL& manifest_url, const char* data, int length,
54 Manifest& manifest) { 54 Manifest& manifest) {
55 // This is an implementation of the parsing algorithm specified in 55 // This is an implementation of the parsing algorithm specified in
56 // the HTML5 offline web application docs: 56 // the HTML5 offline web application docs:
57 // http://www.w3.org/TR/html5/offline.html 57 // http://www.w3.org/TR/html5/offline.html
58 // Do not modify it without consulting those docs. 58 // Do not modify it without consulting those docs.
59 // Though you might be tempted to convert these wstrings to UTF-8 or 59 // Though you might be tempted to convert these wstrings to UTF-8 or
60 // string16, this implementation seems simpler given the constraints. 60 // base::string16, this implementation seems simpler given the constraints.
61 61
62 const wchar_t kSignature[] = L"CACHE MANIFEST"; 62 const wchar_t kSignature[] = L"CACHE MANIFEST";
63 const size_t kSignatureLength = arraysize(kSignature) - 1; 63 const size_t kSignatureLength = arraysize(kSignature) - 1;
64 const wchar_t kChromiumSignature[] = L"CHROMIUM CACHE MANIFEST"; 64 const wchar_t kChromiumSignature[] = L"CHROMIUM CACHE MANIFEST";
65 const size_t kChromiumSignatureLength = arraysize(kChromiumSignature) - 1; 65 const size_t kChromiumSignatureLength = arraysize(kChromiumSignature) - 1;
66 66
67 DCHECK(manifest.explicit_urls.empty()); 67 DCHECK(manifest.explicit_urls.empty());
68 DCHECK(manifest.fallback_namespaces.empty()); 68 DCHECK(manifest.fallback_namespaces.empty());
69 DCHECK(manifest.online_whitelist_namespaces.empty()); 69 DCHECK(manifest.online_whitelist_namespaces.empty());
70 DCHECK(!manifest.online_whitelist_all); 70 DCHECK(!manifest.online_whitelist_all);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 manifest.online_whitelist_all = true; 155 manifest.online_whitelist_all = true;
156 continue; 156 continue;
157 } else if (mode == EXPLICIT || mode == ONLINE_WHITELIST) { 157 } else if (mode == EXPLICIT || mode == ONLINE_WHITELIST) {
158 const wchar_t *line_p = line.c_str(); 158 const wchar_t *line_p = line.c_str();
159 const wchar_t *line_end = line_p + line.length(); 159 const wchar_t *line_end = line_p + line.length();
160 160
161 // Look for whitespace separating the URL from subsequent ignored tokens. 161 // Look for whitespace separating the URL from subsequent ignored tokens.
162 while (line_p < line_end && *line_p != '\t' && *line_p != ' ') 162 while (line_p < line_end && *line_p != '\t' && *line_p != ' ')
163 ++line_p; 163 ++line_p;
164 164
165 string16 url16; 165 base::string16 url16;
166 WideToUTF16(line.c_str(), line_p - line.c_str(), &url16); 166 WideToUTF16(line.c_str(), line_p - line.c_str(), &url16);
167 GURL url = manifest_url.Resolve(url16); 167 GURL url = manifest_url.Resolve(url16);
168 if (!url.is_valid()) 168 if (!url.is_valid())
169 continue; 169 continue;
170 if (url.has_ref()) { 170 if (url.has_ref()) {
171 GURL::Replacements replacements; 171 GURL::Replacements replacements;
172 replacements.ClearRef(); 172 replacements.ClearRef();
173 url = url.ReplaceComponents(replacements); 173 url = url.ReplaceComponents(replacements);
174 } 174 }
175 175
(...skipping 22 matching lines...) Expand all
198 const wchar_t* line_end = line_p + line.length(); 198 const wchar_t* line_end = line_p + line.length();
199 199
200 // Look for first whitespace separating the url namespace from 200 // Look for first whitespace separating the url namespace from
201 // the intercept type. 201 // the intercept type.
202 while (line_p < line_end && *line_p != '\t' && *line_p != ' ') 202 while (line_p < line_end && *line_p != '\t' && *line_p != ' ')
203 ++line_p; 203 ++line_p;
204 204
205 if (line_p == line_end) 205 if (line_p == line_end)
206 continue; // There was no whitespace separating the URLs. 206 continue; // There was no whitespace separating the URLs.
207 207
208 string16 namespace_url16; 208 base::string16 namespace_url16;
209 WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16); 209 WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16);
210 GURL namespace_url = manifest_url.Resolve(namespace_url16); 210 GURL namespace_url = manifest_url.Resolve(namespace_url16);
211 if (!namespace_url.is_valid()) 211 if (!namespace_url.is_valid())
212 continue; 212 continue;
213 if (namespace_url.has_ref()) { 213 if (namespace_url.has_ref()) {
214 GURL::Replacements replacements; 214 GURL::Replacements replacements;
215 replacements.ClearRef(); 215 replacements.ClearRef();
216 namespace_url = namespace_url.ReplaceComponents(replacements); 216 namespace_url = namespace_url.ReplaceComponents(replacements);
217 } 217 }
218 218
(...skipping 18 matching lines...) Expand all
237 237
238 // Skip whitespace separating type from the target_url. 238 // Skip whitespace separating type from the target_url.
239 while (line_p < line_end && (*line_p == '\t' || *line_p == ' ')) 239 while (line_p < line_end && (*line_p == '\t' || *line_p == ' '))
240 ++line_p; 240 ++line_p;
241 241
242 // Look for whitespace separating the URL from subsequent ignored tokens. 242 // Look for whitespace separating the URL from subsequent ignored tokens.
243 const wchar_t* target_url_start = line_p; 243 const wchar_t* target_url_start = line_p;
244 while (line_p < line_end && *line_p != '\t' && *line_p != ' ') 244 while (line_p < line_end && *line_p != '\t' && *line_p != ' ')
245 ++line_p; 245 ++line_p;
246 246
247 string16 target_url16; 247 base::string16 target_url16;
248 WideToUTF16(target_url_start, line_p - target_url_start, &target_url16); 248 WideToUTF16(target_url_start, line_p - target_url_start, &target_url16);
249 GURL target_url = manifest_url.Resolve(target_url16); 249 GURL target_url = manifest_url.Resolve(target_url16);
250 if (!target_url.is_valid()) 250 if (!target_url.is_valid())
251 continue; 251 continue;
252 252
253 if (target_url.has_ref()) { 253 if (target_url.has_ref()) {
254 GURL::Replacements replacements; 254 GURL::Replacements replacements;
255 replacements.ClearRef(); 255 replacements.ClearRef();
256 target_url = target_url.ReplaceComponents(replacements); 256 target_url = target_url.ReplaceComponents(replacements);
257 } 257 }
258 if (manifest_url.GetOrigin() != target_url.GetOrigin()) 258 if (manifest_url.GetOrigin() != target_url.GetOrigin())
259 continue; 259 continue;
260 260
261 manifest.intercept_namespaces.push_back( 261 manifest.intercept_namespaces.push_back(
262 Namespace(INTERCEPT_NAMESPACE, namespace_url, target_url)); 262 Namespace(INTERCEPT_NAMESPACE, namespace_url, target_url));
263 } else if (mode == FALLBACK) { 263 } else if (mode == FALLBACK) {
264 const wchar_t* line_p = line.c_str(); 264 const wchar_t* line_p = line.c_str();
265 const wchar_t* line_end = line_p + line.length(); 265 const wchar_t* line_end = line_p + line.length();
266 266
267 // Look for whitespace separating the two URLs 267 // Look for whitespace separating the two URLs
268 while (line_p < line_end && *line_p != '\t' && *line_p != ' ') 268 while (line_p < line_end && *line_p != '\t' && *line_p != ' ')
269 ++line_p; 269 ++line_p;
270 270
271 if (line_p == line_end) { 271 if (line_p == line_end) {
272 // There was no whitespace separating the URLs. 272 // There was no whitespace separating the URLs.
273 continue; 273 continue;
274 } 274 }
275 275
276 string16 namespace_url16; 276 base::string16 namespace_url16;
277 WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16); 277 WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16);
278 GURL namespace_url = manifest_url.Resolve(namespace_url16); 278 GURL namespace_url = manifest_url.Resolve(namespace_url16);
279 if (!namespace_url.is_valid()) 279 if (!namespace_url.is_valid())
280 continue; 280 continue;
281 if (namespace_url.has_ref()) { 281 if (namespace_url.has_ref()) {
282 GURL::Replacements replacements; 282 GURL::Replacements replacements;
283 replacements.ClearRef(); 283 replacements.ClearRef();
284 namespace_url = namespace_url.ReplaceComponents(replacements); 284 namespace_url = namespace_url.ReplaceComponents(replacements);
285 } 285 }
286 286
287 // Fallback namespace URL must have the same scheme, host and port 287 // Fallback namespace URL must have the same scheme, host and port
288 // as the manifest's URL. 288 // as the manifest's URL.
289 if (manifest_url.GetOrigin() != namespace_url.GetOrigin()) { 289 if (manifest_url.GetOrigin() != namespace_url.GetOrigin()) {
290 continue; 290 continue;
291 } 291 }
292 292
293 // Skip whitespace separating fallback namespace from URL. 293 // Skip whitespace separating fallback namespace from URL.
294 while (line_p < line_end && (*line_p == '\t' || *line_p == ' ')) 294 while (line_p < line_end && (*line_p == '\t' || *line_p == ' '))
295 ++line_p; 295 ++line_p;
296 296
297 // Look for whitespace separating the URL from subsequent ignored tokens. 297 // Look for whitespace separating the URL from subsequent ignored tokens.
298 const wchar_t* fallback_start = line_p; 298 const wchar_t* fallback_start = line_p;
299 while (line_p < line_end && *line_p != '\t' && *line_p != ' ') 299 while (line_p < line_end && *line_p != '\t' && *line_p != ' ')
300 ++line_p; 300 ++line_p;
301 301
302 string16 fallback_url16; 302 base::string16 fallback_url16;
303 WideToUTF16(fallback_start, line_p - fallback_start, &fallback_url16); 303 WideToUTF16(fallback_start, line_p - fallback_start, &fallback_url16);
304 GURL fallback_url = manifest_url.Resolve(fallback_url16); 304 GURL fallback_url = manifest_url.Resolve(fallback_url16);
305 if (!fallback_url.is_valid()) 305 if (!fallback_url.is_valid())
306 continue; 306 continue;
307 if (fallback_url.has_ref()) { 307 if (fallback_url.has_ref()) {
308 GURL::Replacements replacements; 308 GURL::Replacements replacements;
309 replacements.ClearRef(); 309 replacements.ClearRef();
310 fallback_url = fallback_url.ReplaceComponents(replacements); 310 fallback_url = fallback_url.ReplaceComponents(replacements);
311 } 311 }
312 312
313 // Fallback entry URL must have the same scheme, host and port 313 // Fallback entry URL must have the same scheme, host and port
314 // as the manifest's URL. 314 // as the manifest's URL.
315 if (manifest_url.GetOrigin() != fallback_url.GetOrigin()) { 315 if (manifest_url.GetOrigin() != fallback_url.GetOrigin()) {
316 continue; 316 continue;
317 } 317 }
318 318
319 // Store regardless of duplicate namespace URL. Only first match 319 // Store regardless of duplicate namespace URL. Only first match
320 // will ever be used. 320 // will ever be used.
321 manifest.fallback_namespaces.push_back( 321 manifest.fallback_namespaces.push_back(
322 Namespace(FALLBACK_NAMESPACE, namespace_url, fallback_url)); 322 Namespace(FALLBACK_NAMESPACE, namespace_url, fallback_url));
323 } else { 323 } else {
324 NOTREACHED(); 324 NOTREACHED();
325 } 325 }
326 } 326 }
327 327
328 return true; 328 return true;
329 } 329 }
330 330
331 } // namespace appcache 331 } // namespace appcache
OLDNEW
« no previous file with comments | « no previous file | webkit/compositor_bindings/web_layer_impl.cc » ('j') | webkit/database/database_tracker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698