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 "content/browser/service_worker/service_worker_cache.h" | 5 #include "content/browser/service_worker/service_worker_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 880 |
881 // static | 881 // static |
882 void ServiceWorkerCache::PutImpl(scoped_ptr<PutContext> put_context) { | 882 void ServiceWorkerCache::PutImpl(scoped_ptr<PutContext> put_context) { |
883 if (!put_context->cache || !put_context->cache->backend_) { | 883 if (!put_context->cache || !put_context->cache->backend_) { |
884 put_context->callback.Run(ErrorTypeStorage, | 884 put_context->callback.Run(ErrorTypeStorage, |
885 scoped_ptr<ServiceWorkerResponse>(), | 885 scoped_ptr<ServiceWorkerResponse>(), |
886 scoped_ptr<storage::BlobDataHandle>()); | 886 scoped_ptr<storage::BlobDataHandle>()); |
887 return; | 887 return; |
888 } | 888 } |
889 | 889 |
| 890 scoped_ptr<ServiceWorkerFetchRequest> request_copy( |
| 891 new ServiceWorkerFetchRequest(*put_context->request)); |
| 892 ServiceWorkerCache* cache_ptr = put_context->cache.get(); |
| 893 |
| 894 cache_ptr->Delete(request_copy.Pass(), |
| 895 base::Bind(PutDidDelete, base::Passed(put_context.Pass()))); |
| 896 } |
| 897 |
| 898 // static |
| 899 void ServiceWorkerCache::PutDidDelete(scoped_ptr<PutContext> put_context, |
| 900 ErrorType delete_error) { |
| 901 if (!put_context->cache || !put_context->cache->backend_) { |
| 902 put_context->callback.Run(ErrorTypeStorage, |
| 903 scoped_ptr<ServiceWorkerResponse>(), |
| 904 scoped_ptr<storage::BlobDataHandle>()); |
| 905 } |
| 906 |
890 disk_cache::Entry** entry_ptr = &put_context->cache_entry; | 907 disk_cache::Entry** entry_ptr = &put_context->cache_entry; |
891 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); | 908 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); |
892 disk_cache::Backend* backend_ptr = put_context->cache->backend_.get(); | 909 disk_cache::Backend* backend_ptr = put_context->cache->backend_.get(); |
893 | 910 |
894 net::CompletionCallback create_entry_callback = | 911 net::CompletionCallback create_entry_callback = |
895 base::Bind(PutDidCreateEntry, base::Passed(put_context.Pass())); | 912 base::Bind(PutDidCreateEntry, base::Passed(put_context.Pass())); |
896 | 913 |
897 int create_rv = backend_ptr->CreateEntry( | 914 int create_rv = backend_ptr->CreateEntry( |
898 request_ptr->url.spec(), entry_ptr, create_entry_callback); | 915 request_ptr->url.spec(), entry_ptr, create_entry_callback); |
899 | 916 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 initialized_ = true; | 1201 initialized_ = true; |
1185 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); | 1202 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); |
1186 it != init_callbacks_.end(); | 1203 it != init_callbacks_.end(); |
1187 ++it) { | 1204 ++it) { |
1188 it->Run(); | 1205 it->Run(); |
1189 } | 1206 } |
1190 init_callbacks_.clear(); | 1207 init_callbacks_.clear(); |
1191 } | 1208 } |
1192 | 1209 |
1193 } // namespace content | 1210 } // namespace content |
OLD | NEW |