| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/sync_file_system/subtree_set.h" | 5 #include "chrome/browser/sync_file_system/subtree_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "storage/common/fileapi/file_system_util.h" | 9 #include "storage/common/fileapi/file_system_util.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 SubtreeSet::SubtreeSet() {} | 24 SubtreeSet::SubtreeSet() {} |
| 25 SubtreeSet::SubtreeSet(const SubtreeSet& other) = default; | 25 SubtreeSet::SubtreeSet(const SubtreeSet& other) = default; |
| 26 SubtreeSet::~SubtreeSet() {} | 26 SubtreeSet::~SubtreeSet() {} |
| 27 | 27 |
| 28 bool SubtreeSet::IsDisjointWith(const base::FilePath& subtree_root) const { | 28 bool SubtreeSet::IsDisjointWith(const base::FilePath& subtree_root) const { |
| 29 base::FilePath::StringType normalized_subtree_root = | 29 base::FilePath::StringType normalized_subtree_root = |
| 30 storage::VirtualPath::GetNormalizedFilePath(subtree_root); | 30 storage::VirtualPath::GetNormalizedFilePath(subtree_root); |
| 31 | 31 |
| 32 // Check if |subtree_root| contains any of subtrees in the container. | 32 // Check if |subtree_root| contains any of subtrees in the container. |
| 33 if (ContainsKey(inclusive_ancestors_of_subtree_roots_, | 33 if (base::ContainsKey(inclusive_ancestors_of_subtree_roots_, |
| 34 normalized_subtree_root)) | 34 normalized_subtree_root)) |
| 35 return false; | 35 return false; |
| 36 | 36 |
| 37 base::FilePath path(normalized_subtree_root); | 37 base::FilePath path(normalized_subtree_root); |
| 38 while (!storage::VirtualPath::IsRootPath(path)) { | 38 while (!storage::VirtualPath::IsRootPath(path)) { |
| 39 path = storage::VirtualPath::DirName(path); | 39 path = storage::VirtualPath::DirName(path); |
| 40 | 40 |
| 41 Subtrees::const_iterator found = | 41 Subtrees::const_iterator found = |
| 42 inclusive_ancestors_of_subtree_roots_.find(path.value()); | 42 inclusive_ancestors_of_subtree_roots_.find(path.value()); |
| 43 if (found != inclusive_ancestors_of_subtree_roots_.end()) | 43 if (found != inclusive_ancestors_of_subtree_roots_.end()) |
| 44 return !found->second.contained_as_subtree_root; | 44 return !found->second.contained_as_subtree_root; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 size_t SubtreeSet::size() const { | 105 size_t SubtreeSet::size() const { |
| 106 Subtrees::const_iterator found = | 106 Subtrees::const_iterator found = |
| 107 inclusive_ancestors_of_subtree_roots_.find(storage::VirtualPath::kRoot); | 107 inclusive_ancestors_of_subtree_roots_.find(storage::VirtualPath::kRoot); |
| 108 if (found == inclusive_ancestors_of_subtree_roots_.end()) | 108 if (found == inclusive_ancestors_of_subtree_roots_.end()) |
| 109 return 0; | 109 return 0; |
| 110 return found->second.number_of_subtrees_below; | 110 return found->second.number_of_subtrees_below; |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace sync_file_system | 113 } // namespace sync_file_system |
| OLD | NEW |