OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cache_storage/cache_storage_dispatcher_host.h" | 5 #include "content/browser/cache_storage/cache_storage_dispatcher_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); | 196 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); |
197 return; | 197 return; |
198 } | 198 } |
199 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( | 199 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( |
200 new ServiceWorkerFetchRequest(request.url, request.method, | 200 new ServiceWorkerFetchRequest(request.url, request.method, |
201 request.headers, request.referrer, | 201 request.headers, request.referrer, |
202 request.is_reload)); | 202 request.is_reload)); |
203 | 203 |
204 if (match_params.cache_name.is_null()) { | 204 if (match_params.cache_name.is_null()) { |
205 context_->cache_manager()->MatchAllCaches( | 205 context_->cache_manager()->MatchAllCaches( |
206 GURL(origin.Serialize()), std::move(scoped_request), | 206 GURL(origin.Serialize()), std::move(scoped_request), match_params, |
207 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback, | 207 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback, |
208 this, thread_id, request_id)); | 208 this, thread_id, request_id)); |
209 return; | 209 return; |
210 } | 210 } |
211 context_->cache_manager()->MatchCache( | 211 context_->cache_manager()->MatchCache( |
212 GURL(origin.Serialize()), | 212 GURL(origin.Serialize()), |
213 base::UTF16ToUTF8(match_params.cache_name.string()), | 213 base::UTF16ToUTF8(match_params.cache_name.string()), |
214 std::move(scoped_request), | 214 std::move(scoped_request), match_params, |
215 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback, this, | 215 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback, this, |
216 thread_id, request_id)); | 216 thread_id, request_id)); |
217 } | 217 } |
218 | 218 |
219 void CacheStorageDispatcherHost::OnCacheMatch( | 219 void CacheStorageDispatcherHost::OnCacheMatch( |
220 int thread_id, | 220 int thread_id, |
221 int request_id, | 221 int request_id, |
222 int cache_id, | 222 int cache_id, |
223 const ServiceWorkerFetchRequest& request, | 223 const ServiceWorkerFetchRequest& request, |
224 const CacheStorageCacheQueryParams& match_params) { | 224 const CacheStorageCacheQueryParams& match_params) { |
225 IDToCacheMap::iterator it = id_to_cache_map_.find(cache_id); | 225 IDToCacheMap::iterator it = id_to_cache_map_.find(cache_id); |
226 if (it == id_to_cache_map_.end() || !it->second->value()) { | 226 if (it == id_to_cache_map_.end() || !it->second->value()) { |
227 Send(new CacheStorageMsg_CacheMatchError( | 227 Send(new CacheStorageMsg_CacheMatchError( |
228 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); | 228 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); |
229 return; | 229 return; |
230 } | 230 } |
231 | 231 |
232 CacheStorageCache* cache = it->second->value(); | 232 CacheStorageCache* cache = it->second->value(); |
233 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( | 233 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( |
234 new ServiceWorkerFetchRequest(request.url, request.method, | 234 new ServiceWorkerFetchRequest(request.url, request.method, |
235 request.headers, request.referrer, | 235 request.headers, request.referrer, |
236 request.is_reload)); | 236 request.is_reload)); |
237 cache->Match( | 237 cache->Match( |
238 std::move(scoped_request), | 238 std::move(scoped_request), match_params, |
239 base::Bind(&CacheStorageDispatcherHost::OnCacheMatchCallback, this, | 239 base::Bind(&CacheStorageDispatcherHost::OnCacheMatchCallback, this, |
240 thread_id, request_id, base::Passed(it->second->Clone()))); | 240 thread_id, request_id, base::Passed(it->second->Clone()))); |
241 } | 241 } |
242 | 242 |
243 void CacheStorageDispatcherHost::OnCacheMatchAll( | 243 void CacheStorageDispatcherHost::OnCacheMatchAll( |
244 int thread_id, | 244 int thread_id, |
245 int request_id, | 245 int request_id, |
246 int cache_id, | 246 int cache_id, |
247 const ServiceWorkerFetchRequest& request, | 247 const ServiceWorkerFetchRequest& request, |
248 const CacheStorageCacheQueryParams& match_params) { | 248 const CacheStorageCacheQueryParams& match_params) { |
(...skipping 18 matching lines...) Expand all Loading... |
267 request.headers, request.referrer, | 267 request.headers, request.referrer, |
268 request.is_reload)); | 268 request.is_reload)); |
269 if (match_params.ignore_search) { | 269 if (match_params.ignore_search) { |
270 cache->MatchAll( | 270 cache->MatchAll( |
271 std::move(scoped_request), match_params, | 271 std::move(scoped_request), match_params, |
272 base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallback, this, | 272 base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallback, this, |
273 thread_id, request_id, base::Passed(it->second->Clone()))); | 273 thread_id, request_id, base::Passed(it->second->Clone()))); |
274 return; | 274 return; |
275 } | 275 } |
276 cache->Match( | 276 cache->Match( |
277 std::move(scoped_request), | 277 std::move(scoped_request), match_params, |
278 base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallbackAdapter, | 278 base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallbackAdapter, |
279 this, thread_id, request_id, | 279 this, thread_id, request_id, |
280 base::Passed(it->second->Clone()))); | 280 base::Passed(it->second->Clone()))); |
281 } | 281 } |
282 | 282 |
283 void CacheStorageDispatcherHost::OnCacheKeys( | 283 void CacheStorageDispatcherHost::OnCacheKeys( |
284 int thread_id, | 284 int thread_id, |
285 int request_id, | 285 int request_id, |
286 int cache_id, | 286 int cache_id, |
287 const ServiceWorkerFetchRequest& request, | 287 const ServiceWorkerFetchRequest& request, |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); | 545 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); |
546 if (it == blob_handle_store_.end()) | 546 if (it == blob_handle_store_.end()) |
547 return; | 547 return; |
548 DCHECK(!it->second.empty()); | 548 DCHECK(!it->second.empty()); |
549 it->second.pop_front(); | 549 it->second.pop_front(); |
550 if (it->second.empty()) | 550 if (it->second.empty()) |
551 blob_handle_store_.erase(it); | 551 blob_handle_store_.erase(it); |
552 } | 552 } |
553 | 553 |
554 } // namespace content | 554 } // namespace content |
OLD | NEW |