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

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

Issue 18286004: Move PathExists to 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // absolute paths. 252 // absolute paths.
253 void BlockingObliteratePath( 253 void BlockingObliteratePath(
254 const base::FilePath& unnormalized_browser_context_root, 254 const base::FilePath& unnormalized_browser_context_root,
255 const base::FilePath& unnormalized_root, 255 const base::FilePath& unnormalized_root,
256 const std::vector<base::FilePath>& paths_to_keep, 256 const std::vector<base::FilePath>& paths_to_keep,
257 const scoped_refptr<base::TaskRunner>& closure_runner, 257 const scoped_refptr<base::TaskRunner>& closure_runner,
258 const base::Closure& on_gc_required) { 258 const base::Closure& on_gc_required) {
259 // Early exit required because MakeAbsoluteFilePath() will fail on POSIX 259 // Early exit required because MakeAbsoluteFilePath() will fail on POSIX
260 // if |unnormalized_root| does not exist. This is safe because there is 260 // if |unnormalized_root| does not exist. This is safe because there is
261 // nothing to do in this situation anwyays. 261 // nothing to do in this situation anwyays.
262 if (!file_util::PathExists(unnormalized_root)) { 262 if (!base::PathExists(unnormalized_root)) {
263 return; 263 return;
264 } 264 }
265 265
266 // Never try to obliterate things outside of the browser context root or the 266 // Never try to obliterate things outside of the browser context root or the
267 // browser context root itself. Die hard. 267 // browser context root itself. Die hard.
268 base::FilePath root = base::MakeAbsoluteFilePath(unnormalized_root); 268 base::FilePath root = base::MakeAbsoluteFilePath(unnormalized_root);
269 base::FilePath browser_context_root = 269 base::FilePath browser_context_root =
270 base::MakeAbsoluteFilePath(unnormalized_browser_context_root); 270 base::MakeAbsoluteFilePath(unnormalized_browser_context_root);
271 CHECK(!root.empty()); 271 CHECK(!root.empty());
272 CHECK(!browser_context_root.empty()); 272 CHECK(!browser_context_root.empty());
273 CHECK(browser_context_root.IsParent(root) && browser_context_root != root); 273 CHECK(browser_context_root.IsParent(root) && browser_context_root != root);
274 274
275 // Reduce |paths_to_keep| set to those under the root and actually on disk. 275 // Reduce |paths_to_keep| set to those under the root and actually on disk.
276 std::vector<base::FilePath> valid_paths_to_keep; 276 std::vector<base::FilePath> valid_paths_to_keep;
277 for (std::vector<base::FilePath>::const_iterator it = paths_to_keep.begin(); 277 for (std::vector<base::FilePath>::const_iterator it = paths_to_keep.begin();
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) && base::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 base::Delete(root, true); 288 base::Delete(root, true);
289 return; 289 return;
290 } 290 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 579
580 // We do not call InitializeURLRequestContext() for media contexts because, 580 // We do not call InitializeURLRequestContext() for media contexts because,
581 // 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
582 // objects as their associated "normal" request context. Thus, the previous 582 // objects as their associated "normal" request context. Thus, the previous
583 // call serves to initialize the media request context for this storage 583 // call serves to initialize the media request context for this storage
584 // partition as well. 584 // partition as well.
585 } 585 }
586 } 586 }
587 587
588 } // namespace content 588 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698