OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "modules/cachestorage/Cache.h" | 5 #include "modules/cachestorage/Cache.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
10 #include "bindings/core/v8/ExceptionState.h" | 10 #include "bindings/core/v8/ExceptionState.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 class Cache::BarrierCallbackForPut final | 283 class Cache::BarrierCallbackForPut final |
284 : public GarbageCollectedFinalized<BarrierCallbackForPut> { | 284 : public GarbageCollectedFinalized<BarrierCallbackForPut> { |
285 public: | 285 public: |
286 BarrierCallbackForPut(int number_of_operations, | 286 BarrierCallbackForPut(int number_of_operations, |
287 Cache* cache, | 287 Cache* cache, |
288 ScriptPromiseResolver* resolver) | 288 ScriptPromiseResolver* resolver) |
289 : number_of_remaining_operations_(number_of_operations), | 289 : number_of_remaining_operations_(number_of_operations), |
290 cache_(cache), | 290 cache_(cache), |
291 resolver_(resolver) { | 291 resolver_(resolver) { |
292 ASSERT(0 < number_of_remaining_operations_); | 292 DCHECK_LT(0, number_of_remaining_operations_); |
293 batch_operations_.resize(number_of_operations); | 293 batch_operations_.resize(number_of_operations); |
294 } | 294 } |
295 | 295 |
296 void OnSuccess(size_t index, | 296 void OnSuccess(size_t index, |
297 const WebServiceWorkerCache::BatchOperation& batch_operation) { | 297 const WebServiceWorkerCache::BatchOperation& batch_operation) { |
298 ASSERT(index < batch_operations_.size()); | 298 DCHECK_LT(index, batch_operations_.size()); |
299 if (completed_) | 299 if (completed_) |
300 return; | 300 return; |
301 if (!resolver_->GetExecutionContext() || | 301 if (!resolver_->GetExecutionContext() || |
302 resolver_->GetExecutionContext()->IsContextDestroyed()) | 302 resolver_->GetExecutionContext()->IsContextDestroyed()) |
303 return; | 303 return; |
304 batch_operations_[index] = batch_operation; | 304 batch_operations_[index] = batch_operation; |
305 if (--number_of_remaining_operations_ != 0) | 305 if (--number_of_remaining_operations_ != 0) |
306 return; | 306 return; |
307 cache_->WebCache()->DispatchBatch( | 307 cache_->WebCache()->DispatchBatch( |
308 WTF::MakeUnique<CallbackPromiseAdapter<void, CacheStorageError>>( | 308 WTF::MakeUnique<CallbackPromiseAdapter<void, CacheStorageError>>( |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request, | 700 WTF::MakeUnique<CacheWithRequestsCallbacks>(resolver), web_request, |
701 ToWebQueryParams(options)); | 701 ToWebQueryParams(options)); |
702 return promise; | 702 return promise; |
703 } | 703 } |
704 | 704 |
705 WebServiceWorkerCache* Cache::WebCache() const { | 705 WebServiceWorkerCache* Cache::WebCache() const { |
706 return web_cache_.get(); | 706 return web_cache_.get(); |
707 } | 707 } |
708 | 708 |
709 } // namespace blink | 709 } // namespace blink |
OLD | NEW |