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 |
11 namespace sync_file_system { | 11 namespace sync_file_system { |
12 | 12 |
13 SubtreeSet::Node::Node() | 13 SubtreeSet::Node::Node() |
14 : contained_as_subtree_root(false), | 14 : contained_as_subtree_root(false), |
15 number_of_subtrees_below(0) { | 15 number_of_subtrees_below(0) { |
16 } | 16 } |
17 | 17 |
18 SubtreeSet::Node::Node(bool contained_as_subtree_root, | 18 SubtreeSet::Node::Node(bool contained_as_subtree_root, |
19 size_t number_of_subtrees_below) | 19 size_t number_of_subtrees_below) |
20 : contained_as_subtree_root(contained_as_subtree_root), | 20 : contained_as_subtree_root(contained_as_subtree_root), |
21 number_of_subtrees_below(number_of_subtrees_below) { | 21 number_of_subtrees_below(number_of_subtrees_below) { |
22 } | 22 } |
23 | 23 |
24 SubtreeSet::SubtreeSet() {} | 24 SubtreeSet::SubtreeSet() {} |
| 25 SubtreeSet::SubtreeSet(const SubtreeSet& other) = default; |
25 SubtreeSet::~SubtreeSet() {} | 26 SubtreeSet::~SubtreeSet() {} |
26 | 27 |
27 bool SubtreeSet::IsDisjointWith(const base::FilePath& subtree_root) const { | 28 bool SubtreeSet::IsDisjointWith(const base::FilePath& subtree_root) const { |
28 base::FilePath::StringType normalized_subtree_root = | 29 base::FilePath::StringType normalized_subtree_root = |
29 storage::VirtualPath::GetNormalizedFilePath(subtree_root); | 30 storage::VirtualPath::GetNormalizedFilePath(subtree_root); |
30 | 31 |
31 // Check if |subtree_root| contains any of subtrees in the container. | 32 // Check if |subtree_root| contains any of subtrees in the container. |
32 if (ContainsKey(inclusive_ancestors_of_subtree_roots_, | 33 if (ContainsKey(inclusive_ancestors_of_subtree_roots_, |
33 normalized_subtree_root)) | 34 normalized_subtree_root)) |
34 return false; | 35 return false; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 104 |
104 size_t SubtreeSet::size() const { | 105 size_t SubtreeSet::size() const { |
105 Subtrees::const_iterator found = | 106 Subtrees::const_iterator found = |
106 inclusive_ancestors_of_subtree_roots_.find(storage::VirtualPath::kRoot); | 107 inclusive_ancestors_of_subtree_roots_.find(storage::VirtualPath::kRoot); |
107 if (found == inclusive_ancestors_of_subtree_roots_.end()) | 108 if (found == inclusive_ancestors_of_subtree_roots_.end()) |
108 return 0; | 109 return 0; |
109 return found->second.number_of_subtrees_below; | 110 return found->second.number_of_subtrees_below; |
110 } | 111 } |
111 | 112 |
112 } // namespace sync_file_system | 113 } // namespace sync_file_system |
OLD | NEW |