| 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 "components/browsing_data/storage_partition_http_cache_data_remover.h" | 5 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
| 6 | 6 |
| 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" |
| 7 #include "components/browsing_data/conditional_cache_deletion_helper.h" | 10 #include "components/browsing_data/conditional_cache_deletion_helper.h" |
| 8 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/storage_partition.h" | 12 #include "content/public/browser/storage_partition.h" |
| 10 #include "net/base/sdch_manager.h" | 13 #include "net/base/sdch_manager.h" |
| 11 #include "net/disk_cache/blockfile/backend_impl.h" | 14 #include "net/disk_cache/blockfile/backend_impl.h" |
| 12 #include "net/disk_cache/disk_cache.h" | 15 #include "net/disk_cache/disk_cache.h" |
| 13 #include "net/disk_cache/memory/mem_backend_impl.h" | 16 #include "net/disk_cache/memory/mem_backend_impl.h" |
| 14 #include "net/disk_cache/simple/simple_backend_impl.h" | 17 #include "net/disk_cache/simple/simple_backend_impl.h" |
| 15 #include "net/http/http_cache.h" | 18 #include "net/http/http_cache.h" |
| 16 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 DCHECK(main_context_getter_.get()); | 113 DCHECK(main_context_getter_.get()); |
| 111 DCHECK(media_context_getter_.get()); | 114 DCHECK(media_context_getter_.get()); |
| 112 | 115 |
| 113 next_cache_state_ = STATE_CREATE_MAIN; | 116 next_cache_state_ = STATE_CREATE_MAIN; |
| 114 DoCountCache(net::OK); | 117 DoCountCache(net::OK); |
| 115 } | 118 } |
| 116 | 119 |
| 117 void StoragePartitionHttpCacheDataRemover::ClearedHttpCache() { | 120 void StoragePartitionHttpCacheDataRemover::ClearedHttpCache() { |
| 118 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 121 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 119 done_callback_.Run(); | 122 done_callback_.Run(); |
| 120 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 123 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 121 } | 124 } |
| 122 | 125 |
| 123 void StoragePartitionHttpCacheDataRemover::CountedHttpCache() { | 126 void StoragePartitionHttpCacheDataRemover::CountedHttpCache() { |
| 124 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 127 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 125 result_callback_.Run(calculation_result_); | 128 result_callback_.Run(calculation_result_); |
| 126 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 129 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 127 } | 130 } |
| 128 | 131 |
| 129 // The expected state sequence is STATE_NONE --> STATE_CREATE_MAIN --> | 132 // The expected state sequence is STATE_NONE --> STATE_CREATE_MAIN --> |
| 130 // STATE_PROCESS_MAIN --> STATE_CREATE_MEDIA --> STATE_PROCESS_MEDIA --> | 133 // STATE_PROCESS_MAIN --> STATE_CREATE_MEDIA --> STATE_PROCESS_MEDIA --> |
| 131 // STATE_DONE, and any errors are ignored. | 134 // STATE_DONE, and any errors are ignored. |
| 132 void StoragePartitionHttpCacheDataRemover::DoClearCache(int rv) { | 135 void StoragePartitionHttpCacheDataRemover::DoClearCache(int rv) { |
| 133 DCHECK_NE(STATE_NONE, next_cache_state_); | 136 DCHECK_NE(STATE_NONE, next_cache_state_); |
| 134 | 137 |
| 135 while (rv != net::ERR_IO_PENDING && next_cache_state_ != STATE_NONE) { | 138 while (rv != net::ERR_IO_PENDING && next_cache_state_ != STATE_NONE) { |
| 136 switch (next_cache_state_) { | 139 switch (next_cache_state_) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 default: { | 301 default: { |
| 299 NOTREACHED() << "bad state"; | 302 NOTREACHED() << "bad state"; |
| 300 next_cache_state_ = STATE_NONE; // Stop looping. | 303 next_cache_state_ = STATE_NONE; // Stop looping. |
| 301 return; | 304 return; |
| 302 } | 305 } |
| 303 } | 306 } |
| 304 } | 307 } |
| 305 } | 308 } |
| 306 | 309 |
| 307 } // namespace browsing_data | 310 } // namespace browsing_data |
| OLD | NEW |