| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_ | |
| 6 #define SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 | |
| 13 namespace fake_server { | |
| 14 | |
| 15 class SessionsHierarchy; | |
| 16 | |
| 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(); | |
| 23 | |
| 24 ~SessionsHierarchy(); | |
| 25 | |
| 26 // Add a window to the builder with one tab. | |
| 27 void AddWindow(const std::string& tab); | |
| 28 | |
| 29 // Add a window to the builder with multiple tabs. | |
| 30 void AddWindow(const std::multiset<std::string>& tabs); | |
| 31 | |
| 32 // Creates and returns a human-readable string version of this object's data. | |
| 33 std::string ToString() const; | |
| 34 | |
| 35 // Returns true when this object and |other| have equivalent data. | |
| 36 // | |
| 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). | |
| 41 // | |
| 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; | |
| 47 | |
| 48 private: | |
| 49 // A collection of tab URLs. | |
| 50 typedef std::multiset<std::string> Window; | |
| 51 | |
| 52 // A collection of Windows (an instance of this collection represents a | |
| 53 // sessions hierarchy). | |
| 54 typedef std::multiset<Window> WindowContainer; | |
| 55 | |
| 56 // The windows of the sessions hierarchy. | |
| 57 WindowContainer windows_; | |
| 58 }; | |
| 59 | |
| 60 } // namespace fake_server | |
| 61 | |
| 62 #endif // SYNC_TEST_FAKE_SERVER_SESSIONS_HIERARCHY_H_ | |
| OLD | NEW |