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 "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_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // Synchronously attempts to delete |unnormalized_root|, preserving only | 247 // Synchronously attempts to delete |unnormalized_root|, preserving only |
248 // entries in |paths_to_keep|. If there are no entries in |paths_to_keep| on | 248 // entries in |paths_to_keep|. If there are no entries in |paths_to_keep| on |
249 // disk, then it completely removes |unnormalized_root|. All paths must be | 249 // disk, then it completely removes |unnormalized_root|. All paths must be |
250 // absolute paths. | 250 // absolute paths. |
251 void BlockingObliteratePath( | 251 void BlockingObliteratePath( |
252 const base::FilePath& unnormalized_browser_context_root, | 252 const base::FilePath& unnormalized_browser_context_root, |
253 const base::FilePath& unnormalized_root, | 253 const base::FilePath& unnormalized_root, |
254 const std::vector<base::FilePath>& paths_to_keep, | 254 const std::vector<base::FilePath>& paths_to_keep, |
255 const scoped_refptr<base::TaskRunner>& closure_runner, | 255 const scoped_refptr<base::TaskRunner>& closure_runner, |
256 const base::Closure& on_gc_required) { | 256 const base::Closure& on_gc_required) { |
257 // Early exit required because file_util::AbsolutePath() will fail on POSIX | 257 // Early exit required because MakeAbsoluteFilePath() will fail on POSIX |
258 // if |unnormalized_root| does not exist. This is safe because there is | 258 // if |unnormalized_root| does not exist. This is safe because there is |
259 // nothing to do in this situation anwyays. | 259 // nothing to do in this situation anwyays. |
260 if (!file_util::PathExists(unnormalized_root)) { | 260 if (!file_util::PathExists(unnormalized_root)) { |
261 return; | 261 return; |
262 } | 262 } |
263 | 263 |
264 // Never try to obliterate things outside of the browser context root or the | 264 // Never try to obliterate things outside of the browser context root or the |
265 // browser context root itself. Die hard. | 265 // browser context root itself. Die hard. |
266 base::FilePath root = unnormalized_root; | 266 base::FilePath root = base::MakeAbsoluteFilePath(unnormalized_root); |
267 base::FilePath browser_context_root = unnormalized_browser_context_root; | 267 base::FilePath browser_context_root = |
268 CHECK(file_util::AbsolutePath(&root)); | 268 base::MakeAbsoluteFilePath(unnormalized_browser_context_root); |
269 CHECK(file_util::AbsolutePath(&browser_context_root)); | 269 CHECK(!root.empty()); |
270 CHECK(file_util::ContainsPath(browser_context_root, root) && | 270 CHECK(!browser_context_root.empty()); |
271 browser_context_root != root); | 271 CHECK(browser_context_root.IsParent(root) && browser_context_root != root); |
272 | 272 |
273 // Reduce |paths_to_keep| set to those under the root and actually on disk. | 273 // Reduce |paths_to_keep| set to those under the root and actually on disk. |
274 std::vector<base::FilePath> valid_paths_to_keep; | 274 std::vector<base::FilePath> valid_paths_to_keep; |
275 for (std::vector<base::FilePath>::const_iterator it = paths_to_keep.begin(); | 275 for (std::vector<base::FilePath>::const_iterator it = paths_to_keep.begin(); |
276 it != paths_to_keep.end(); | 276 it != paths_to_keep.end(); |
277 ++it) { | 277 ++it) { |
278 if (root.IsParent(*it) && file_util::PathExists(*it)) | 278 if (root.IsParent(*it) && file_util::PathExists(*it)) |
279 valid_paths_to_keep.push_back(*it); | 279 valid_paths_to_keep.push_back(*it); |
280 } | 280 } |
281 | 281 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 577 |
578 // We do not call InitializeURLRequestContext() for media contexts because, | 578 // We do not call InitializeURLRequestContext() for media contexts because, |
579 // other than the HTTP cache, the media contexts share the same backing | 579 // other than the HTTP cache, the media contexts share the same backing |
580 // objects as their associated "normal" request context. Thus, the previous | 580 // objects as their associated "normal" request context. Thus, the previous |
581 // call serves to initialize the media request context for this storage | 581 // call serves to initialize the media request context for this storage |
582 // partition as well. | 582 // partition as well. |
583 } | 583 } |
584 } | 584 } |
585 | 585 |
586 } // namespace content | 586 } // namespace content |
OLD | NEW |