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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SUBTREE_SET_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SUBTREE_SET_H_
8 #include "base/containers/hash_tables.h"
9 #include "base/files/file_path.h"
15 namespace sync_file_system
{
17 // Stores disjoint subtrees of a directory tree.
23 // Returns true if the subtree induced by |subtree_root| is disjoint with
24 // all subtrees in the container.
25 bool IsDisjointWith(const base::FilePath
& subtree_root
) const;
27 // Returns true and inserts the subtree induced by |subtree_root| if the
28 // subtree is disjoint with all subtrees in the container.
29 bool insert(const base::FilePath
& subtree_root
);
31 // Erases the subtree induced by |subtree_root| from the container.
32 // Returns true if this erases the subtree.
33 bool erase(const base::FilePath
& subtree_root
);
36 bool empty() const { return inclusive_ancestors_of_subtree_roots_
.empty(); }
40 bool contained_as_subtree_root
;
41 size_t number_of_subtrees_below
;
44 Node(bool contained_as_subtree_root
,
45 size_t number_of_subtrees_below
);
48 typedef base::FilePath::StringType StringType
;
49 typedef base::hash_map
<StringType
, Node
> Subtrees
;
51 // Contains the root of subtrees and all upward node to root.
52 // Each subtree root has |contained_as_subtree_root| flag true.
53 Subtrees inclusive_ancestors_of_subtree_roots_
;
56 } // namespace sync_file_system
58 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SUBTREE_SET_H_