OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/disk_cache/backend_impl.h" | 5 #include "net/disk_cache/backend_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 // possible at this time, at the price of leaving dirty entries behind. | 362 // possible at this time, at the price of leaving dirty entries behind. |
363 background_queue_.DropPendingIO(); | 363 background_queue_.DropPendingIO(); |
364 } | 364 } |
365 | 365 |
366 if (background_queue_.BackgroundIsCurrentThread()) { | 366 if (background_queue_.BackgroundIsCurrentThread()) { |
367 // Unit tests may use the same thread for everything. | 367 // Unit tests may use the same thread for everything. |
368 CleanupCache(); | 368 CleanupCache(); |
369 } else { | 369 } else { |
370 background_queue_.background_thread()->PostTask( | 370 background_queue_.background_thread()->PostTask( |
371 FROM_HERE, base::Bind(&FinalCleanupCallback, base::Unretained(this))); | 371 FROM_HERE, base::Bind(&FinalCleanupCallback, base::Unretained(this))); |
| 372 // http://crbug.com/74623 |
| 373 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
372 done_.Wait(); | 374 done_.Wait(); |
373 } | 375 } |
374 } | 376 } |
375 | 377 |
376 // If the initialization of the cache fails, and force is true, we will discard | 378 // If the initialization of the cache fails, and force is true, we will discard |
377 // the whole cache and create a new one. In order to process a potentially large | 379 // the whole cache and create a new one. In order to process a potentially large |
378 // number of files, we'll rename the cache folder to old_ + original_name + | 380 // number of files, we'll rename the cache folder to old_ + original_name + |
379 // number, (located on the same parent folder), and spawn a worker thread to | 381 // number, (located on the same parent folder), and spawn a worker thread to |
380 // delete all the files on all the stale cache folders. The whole process can | 382 // delete all the files on all the stale cache folders. The whole process can |
381 // still fail if we are not able to rename the cache folder (for instance due to | 383 // still fail if we are not able to rename the cache folder (for instance due to |
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2172 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2171 total_memory = kMaxBuffersSize; | 2173 total_memory = kMaxBuffersSize; |
2172 | 2174 |
2173 done = true; | 2175 done = true; |
2174 } | 2176 } |
2175 | 2177 |
2176 return static_cast<int>(total_memory); | 2178 return static_cast<int>(total_memory); |
2177 } | 2179 } |
2178 | 2180 |
2179 } // namespace disk_cache | 2181 } // namespace disk_cache |
OLD | NEW |