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 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "url/gurl.h" |
12 | 14 |
13 namespace chromeos { | 15 namespace chromeos { |
14 namespace file_system_provider { | 16 namespace file_system_provider { |
15 | 17 |
16 struct ObservedEntry; | 18 struct ObservedEntry; |
| 19 struct Subscriber; |
17 | 20 |
18 // Key for storing an observed entry in the map. | 21 // Key for storing an observed entry in the map. |
19 struct ObservedEntryKey { | 22 struct ObservedEntryKey { |
20 ObservedEntryKey(const base::FilePath& entry_path, bool recursive); | 23 ObservedEntryKey(const base::FilePath& entry_path, bool recursive); |
21 ~ObservedEntryKey(); | 24 ~ObservedEntryKey(); |
22 | 25 |
23 struct Comparator { | 26 struct Comparator { |
24 bool operator()(const ObservedEntryKey& a, const ObservedEntryKey& b) const; | 27 bool operator()(const ObservedEntryKey& a, const ObservedEntryKey& b) const; |
25 }; | 28 }; |
26 | 29 |
27 base::FilePath entry_path; | 30 base::FilePath entry_path; |
28 bool recursive; | 31 bool recursive; |
29 }; | 32 }; |
30 | 33 |
31 // List of observed entries. | 34 // List of observed entries. |
32 typedef std::map<ObservedEntryKey, ObservedEntry, ObservedEntryKey::Comparator> | 35 typedef std::map<ObservedEntryKey, ObservedEntry, ObservedEntryKey::Comparator> |
33 ObservedEntries; | 36 ObservedEntries; |
34 | 37 |
| 38 // Map of subscribers for notifications about an observed entry. |
| 39 typedef std::map<GURL, Subscriber> Subscribers; |
| 40 |
| 41 // Represents a subscriber for notification about an observed entry. There may |
| 42 // be up to one subscriber per origin for the same observed entry. |
| 43 struct Subscriber { |
| 44 Subscriber(); |
| 45 ~Subscriber(); |
| 46 |
| 47 GURL origin; |
| 48 bool persistent; |
| 49 }; |
| 50 |
35 // Represents an observed entry on a file system. | 51 // Represents an observed entry on a file system. |
36 struct ObservedEntry { | 52 struct ObservedEntry { |
37 ObservedEntry(); | 53 ObservedEntry(); |
38 ~ObservedEntry(); | 54 ~ObservedEntry(); |
39 | 55 |
| 56 // Map of subscribers for notifications of the observed entry. |
| 57 Subscribers subscribers; |
| 58 |
| 59 // Path of the observed entry. |
40 base::FilePath entry_path; | 60 base::FilePath entry_path; |
| 61 |
| 62 // Whether observing is recursive or not. |
41 bool recursive; | 63 bool recursive; |
| 64 |
| 65 // Tag of the last notification for this observed entry. May be empty if not |
| 66 // supported. |
42 std::string last_tag; | 67 std::string last_tag; |
43 }; | 68 }; |
44 | 69 |
45 } // namespace file_system_provider | 70 } // namespace file_system_provider |
46 } // namespace chromeos | 71 } // namespace chromeos |
47 | 72 |
48 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ | 73 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ |
OLD | NEW |