| 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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 | 810 |
| 811 // static | 811 // static |
| 812 void ServiceWorkerCache::PutImpl(scoped_ptr<PutContext> put_context) { | 812 void ServiceWorkerCache::PutImpl(scoped_ptr<PutContext> put_context) { |
| 813 if (!put_context->cache || !put_context->cache->backend_) { | 813 if (!put_context->cache || !put_context->cache->backend_) { |
| 814 put_context->callback.Run(ErrorTypeStorage, | 814 put_context->callback.Run(ErrorTypeStorage, |
| 815 scoped_ptr<ServiceWorkerResponse>(), | 815 scoped_ptr<ServiceWorkerResponse>(), |
| 816 scoped_ptr<storage::BlobDataHandle>()); | 816 scoped_ptr<storage::BlobDataHandle>()); |
| 817 return; | 817 return; |
| 818 } | 818 } |
| 819 | 819 |
| 820 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); |
| 821 disk_cache::Backend* backend_ptr = put_context->cache->backend_.get(); |
| 822 |
| 823 net::CompletionCallback doom_entry_callback = |
| 824 base::Bind(PutDidDoomEntry, base::Passed(put_context.Pass())); |
| 825 |
| 826 int rv = backend_ptr->DoomEntry(request_ptr->url.spec(), doom_entry_callback); |
| 827 if (rv != net::ERR_IO_PENDING) |
| 828 doom_entry_callback.Run(rv); |
| 829 } |
| 830 |
| 831 // static |
| 832 void ServiceWorkerCache::PutDidDoomEntry(scoped_ptr<PutContext> put_context, |
| 833 int doom_rv) { |
| 834 if (!put_context->cache || !put_context->cache->backend_) { |
| 835 put_context->callback.Run(ErrorTypeStorage, |
| 836 scoped_ptr<ServiceWorkerResponse>(), |
| 837 scoped_ptr<storage::BlobDataHandle>()); |
| 838 } |
| 839 |
| 820 disk_cache::Entry** entry_ptr = &put_context->cache_entry; | 840 disk_cache::Entry** entry_ptr = &put_context->cache_entry; |
| 821 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); | 841 ServiceWorkerFetchRequest* request_ptr = put_context->request.get(); |
| 822 disk_cache::Backend* backend_ptr = put_context->cache->backend_.get(); | 842 disk_cache::Backend* backend_ptr = put_context->cache->backend_.get(); |
| 823 | 843 |
| 824 net::CompletionCallback create_entry_callback = | 844 net::CompletionCallback create_entry_callback = |
| 825 base::Bind(PutDidCreateEntry, base::Passed(put_context.Pass())); | 845 base::Bind(PutDidCreateEntry, base::Passed(put_context.Pass())); |
| 826 | 846 |
| 827 int create_rv = backend_ptr->CreateEntry( | 847 int create_rv = backend_ptr->CreateEntry( |
| 828 request_ptr->url.spec(), entry_ptr, create_entry_callback); | 848 request_ptr->url.spec(), entry_ptr, create_entry_callback); |
| 829 | 849 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 initialized_ = true; | 1114 initialized_ = true; |
| 1095 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); | 1115 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); |
| 1096 it != init_callbacks_.end(); | 1116 it != init_callbacks_.end(); |
| 1097 ++it) { | 1117 ++it) { |
| 1098 it->Run(); | 1118 it->Run(); |
| 1099 } | 1119 } |
| 1100 init_callbacks_.clear(); | 1120 init_callbacks_.clear(); |
| 1101 } | 1121 } |
| 1102 | 1122 |
| 1103 } // namespace content | 1123 } // namespace content |
| OLD | NEW |