Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / sync / test / fake_server / sessions_hierarchy.h
blobeac1541b0f9ee9c348c7045ba22f89df43ed2b8b
1 // Copyright 2015 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 SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_
6 #define SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_
8 #include <set>
9 #include <string>
11 #include "base/macros.h"
13 namespace fake_server {
15 class SessionsHierarchy;
17 // A representation of the Sync Sessions hierarchy (windows and the URLs of
18 // their tabs).
19 class SessionsHierarchy {
20 public:
21 // Creates an empty (no windows) SessionsHierachy.
22 SessionsHierarchy();
24 ~SessionsHierarchy();
26 // Add a window to the builder with one tab.
27 void AddWindow(const std::string& tab);
29 // Add a window to the builder with multiple tabs.
30 void AddWindow(const std::multiset<std::string>& tabs);
32 // Creates and returns a human-readable string version of this object's data.
33 std::string ToString() const;
35 // Returns true when this object and |other| have equivalent data.
37 // Two SessionHierarchy objects A and B have equivalent data iff:
38 // 1) A and B contain the same number of Windows, and
39 // 2) Each Window of A is equal (as a multiset) to exactly one Window of B
40 // (and vice versa).
42 // Examples of equivalent hierarchies:
43 // {} and {}, {{X}} and {{X}}, {{X,Y}} and {{Y,X}}, {{X},{Y}} and {{Y},{X}}
44 // Examples of nonequivalent hierarchies:
45 // {{X}} and {{Y}}, {{X}} and {{X,X}}, {{X}} and {{X},{X}}
46 bool Equals(const SessionsHierarchy& other) const;
48 private:
49 // A collection of tab URLs.
50 typedef std::multiset<std::string> Window;
52 // A collection of Windows (an instance of this collection represents a
53 // sessions hierarchy).
54 typedef std::multiset<Window> WindowContainer;
56 // The windows of the sessions hierarchy.
57 WindowContainer windows_;
60 } // namespace fake_server
62 #endif // SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_