Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Side by Side Diff: content/browser/storage_partition_impl_map.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/storage_partition_impl_map.h" 5 #include "content/browser/storage_partition_impl_map.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } else if (to_delete.IsParent(*to_keep)) { 226 } else if (to_delete.IsParent(*to_keep)) {
227 // |to_delete| contains a path to keep. Add to stack for further 227 // |to_delete| contains a path to keep. Add to stack for further
228 // processing. 228 // processing.
229 action = kEnqueue; 229 action = kEnqueue;
230 break; 230 break;
231 } 231 }
232 } 232 }
233 233
234 switch (action) { 234 switch (action) {
235 case kDelete: 235 case kDelete:
236 file_util::Delete(to_delete, true); 236 base::Delete(to_delete, true);
237 break; 237 break;
238 238
239 case kEnqueue: 239 case kEnqueue:
240 paths_to_consider->push_back(to_delete); 240 paths_to_consider->push_back(to_delete);
241 break; 241 break;
242 242
243 case kSkip: 243 case kSkip:
244 break; 244 break;
245 } 245 }
246 } 246 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 it != paths_to_keep.end(); 278 it != paths_to_keep.end();
279 ++it) { 279 ++it) {
280 if (root.IsParent(*it) && file_util::PathExists(*it)) 280 if (root.IsParent(*it) && file_util::PathExists(*it))
281 valid_paths_to_keep.push_back(*it); 281 valid_paths_to_keep.push_back(*it);
282 } 282 }
283 283
284 // If none of the |paths_to_keep| are valid anymore then we just whack the 284 // If none of the |paths_to_keep| are valid anymore then we just whack the
285 // root and be done with it. Otherwise, signal garbage collection and do 285 // root and be done with it. Otherwise, signal garbage collection and do
286 // a best-effort delete of the on-disk structures. 286 // a best-effort delete of the on-disk structures.
287 if (valid_paths_to_keep.empty()) { 287 if (valid_paths_to_keep.empty()) {
288 file_util::Delete(root, true); 288 base::Delete(root, true);
289 return; 289 return;
290 } 290 }
291 closure_runner->PostTask(FROM_HERE, on_gc_required); 291 closure_runner->PostTask(FROM_HERE, on_gc_required);
292 292
293 // Otherwise, start at the root and delete everything that is not in 293 // Otherwise, start at the root and delete everything that is not in
294 // |valid_paths_to_keep|. 294 // |valid_paths_to_keep|.
295 std::vector<base::FilePath> paths_to_consider; 295 std::vector<base::FilePath> paths_to_consider;
296 paths_to_consider.push_back(root); 296 paths_to_consider.push_back(root);
297 while(!paths_to_consider.empty()) { 297 while(!paths_to_consider.empty()) {
298 base::FilePath path = paths_to_consider.back(); 298 base::FilePath path = paths_to_consider.back();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (active_paths->find(path) == active_paths->end() && 336 if (active_paths->find(path) == active_paths->end() &&
337 path != trash_directory) { 337 path != trash_directory) {
338 // Since |trash_directory| is unique for each run of this function there 338 // Since |trash_directory| is unique for each run of this function there
339 // can be no colllisions on the move. 339 // can be no colllisions on the move.
340 file_util::Move(path, trash_directory.Append(path.BaseName())); 340 file_util::Move(path, trash_directory.Append(path.BaseName()));
341 } 341 }
342 } 342 }
343 343
344 file_access_runner->PostTask( 344 file_access_runner->PostTask(
345 FROM_HERE, 345 FROM_HERE,
346 base::Bind(base::IgnoreResult(&file_util::Delete), trash_directory, 346 base::Bind(base::IgnoreResult(&base::Delete), trash_directory, true));
347 true));
348 } 347 }
349 348
350 } // namespace 349 } // namespace
351 350
352 // static 351 // static
353 base::FilePath StoragePartitionImplMap::GetStoragePartitionPath( 352 base::FilePath StoragePartitionImplMap::GetStoragePartitionPath(
354 const std::string& partition_domain, 353 const std::string& partition_domain,
355 const std::string& partition_name) { 354 const std::string& partition_name) {
356 if (partition_domain.empty()) 355 if (partition_domain.empty())
357 return base::FilePath(); 356 return base::FilePath();
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 579
581 // We do not call InitializeURLRequestContext() for media contexts because, 580 // We do not call InitializeURLRequestContext() for media contexts because,
582 // other than the HTTP cache, the media contexts share the same backing 581 // other than the HTTP cache, the media contexts share the same backing
583 // objects as their associated "normal" request context. Thus, the previous 582 // objects as their associated "normal" request context. Thus, the previous
584 // call serves to initialize the media request context for this storage 583 // call serves to initialize the media request context for this storage
585 // partition as well. 584 // partition as well.
586 } 585 }
587 } 586 }
588 587
589 } // namespace content 588 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698