OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/appcache/appcache.h" | 5 #include "content/browser/appcache/appcache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return GURL(); | 126 return GURL(); |
127 } | 127 } |
128 | 128 |
129 namespace { | 129 namespace { |
130 bool SortNamespacesByLength( | 130 bool SortNamespacesByLength( |
131 const AppCacheNamespace& lhs, const AppCacheNamespace& rhs) { | 131 const AppCacheNamespace& lhs, const AppCacheNamespace& rhs) { |
132 return lhs.namespace_url.spec().length() > rhs.namespace_url.spec().length(); | 132 return lhs.namespace_url.spec().length() > rhs.namespace_url.spec().length(); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 void AppCache::InitializeWithManifest(Manifest* manifest) { | 136 void AppCache::InitializeWithManifest(AppCacheManifest* manifest) { |
137 DCHECK(manifest); | 137 DCHECK(manifest); |
138 intercept_namespaces_.swap(manifest->intercept_namespaces); | 138 intercept_namespaces_.swap(manifest->intercept_namespaces); |
139 fallback_namespaces_.swap(manifest->fallback_namespaces); | 139 fallback_namespaces_.swap(manifest->fallback_namespaces); |
140 online_whitelist_namespaces_.swap(manifest->online_whitelist_namespaces); | 140 online_whitelist_namespaces_.swap(manifest->online_whitelist_namespaces); |
141 online_whitelist_all_ = manifest->online_whitelist_all; | 141 online_whitelist_all_ = manifest->online_whitelist_all; |
142 | 142 |
143 // Sort the namespaces by url string length, longest to shortest, | 143 // Sort the namespaces by url string length, longest to shortest, |
144 // since longer matches trump when matching a url to a namespace. | 144 // since longer matches trump when matching a url to a namespace. |
145 std::sort(intercept_namespaces_.begin(), intercept_namespaces_.end(), | 145 std::sort(intercept_namespaces_.begin(), intercept_namespaces_.end(), |
146 SortNamespacesByLength); | 146 SortNamespacesByLength); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 const GURL& url) { | 318 const GURL& url) { |
319 size_t count = namespaces.size(); | 319 size_t count = namespaces.size(); |
320 for (size_t i = 0; i < count; ++i) { | 320 for (size_t i = 0; i < count; ++i) { |
321 if (namespaces[i].IsMatch(url)) | 321 if (namespaces[i].IsMatch(url)) |
322 return &namespaces[i]; | 322 return &namespaces[i]; |
323 } | 323 } |
324 return NULL; | 324 return NULL; |
325 } | 325 } |
326 | 326 |
327 } // namespace content | 327 } // namespace content |
OLD | NEW |