OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/browsing_data/conditional_cache_deletion_helper.h" | 5 #include "components/browsing_data/conditional_cache_deletion_helper.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" |
8 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
9 | 12 |
10 namespace { | 13 namespace { |
11 | 14 |
12 bool EntryPredicateFromURLsAndTime( | 15 bool EntryPredicateFromURLsAndTime( |
13 const base::Callback<bool(const GURL&)>& url_predicate, | 16 const base::Callback<bool(const GURL&)>& url_predicate, |
14 const base::Time& begin_time, | 17 const base::Time& begin_time, |
15 const base::Time& end_time, | 18 const base::Time& end_time, |
16 const disk_cache::Entry* entry) { | 19 const disk_cache::Entry* entry) { |
17 return (entry->GetLastModified() >= begin_time && | 20 return (entry->GetLastModified() >= begin_time && |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 previous_entry_->Doom(); | 74 previous_entry_->Doom(); |
72 previous_entry_->Close(); | 75 previous_entry_->Close(); |
73 } | 76 } |
74 | 77 |
75 if (error == net::ERR_FAILED) { | 78 if (error == net::ERR_FAILED) { |
76 // The iteration finished successfuly or we can no longer iterate | 79 // The iteration finished successfuly or we can no longer iterate |
77 // (e.g. the cache was destroyed). We cannot distinguish between the two, | 80 // (e.g. the cache was destroyed). We cannot distinguish between the two, |
78 // but we know that there is nothing more that we can do, so we return OK. | 81 // but we know that there is nothing more that we can do, so we return OK. |
79 base::MessageLoop::current()->task_runner()->PostTask( | 82 base::MessageLoop::current()->task_runner()->PostTask( |
80 FROM_HERE, base::Bind(completion_callback_, net::OK)); | 83 FROM_HERE, base::Bind(completion_callback_, net::OK)); |
81 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 84 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
82 return; | 85 return; |
83 } | 86 } |
84 | 87 |
85 previous_entry_ = current_entry_; | 88 previous_entry_ = current_entry_; |
86 error = iterator_->OpenNextEntry( | 89 error = iterator_->OpenNextEntry( |
87 ¤t_entry_, | 90 ¤t_entry_, |
88 base::Bind(&ConditionalCacheDeletionHelper::IterateOverEntries, | 91 base::Bind(&ConditionalCacheDeletionHelper::IterateOverEntries, |
89 base::Unretained(this))); | 92 base::Unretained(this))); |
90 } | 93 } |
91 } | 94 } |
92 | 95 |
93 } // namespace browsing_data | 96 } // namespace browsing_data |
OLD | NEW |