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. There may be two observers | 21 // Key for storing an observed entry in the map. There may be two observers |
19 // per path, as long as one is recursive, and the other one not. | 22 // per path, as long as one is recursive, and the other one not. |
20 struct ObservedEntryKey { | 23 struct ObservedEntryKey { |
21 ObservedEntryKey(const base::FilePath& entry_path, bool recursive); | 24 ObservedEntryKey(const base::FilePath& entry_path, bool recursive); |
22 ~ObservedEntryKey(); | 25 ~ObservedEntryKey(); |
23 | 26 |
24 struct Comparator { | 27 struct Comparator { |
25 bool operator()(const ObservedEntryKey& a, const ObservedEntryKey& b) const; | 28 bool operator()(const ObservedEntryKey& a, const ObservedEntryKey& b) const; |
26 }; | 29 }; |
27 | 30 |
28 base::FilePath entry_path; | 31 base::FilePath entry_path; |
29 bool recursive; | 32 bool recursive; |
30 }; | 33 }; |
31 | 34 |
32 // List of observed entries. | 35 // List of observed entries. |
33 typedef std::map<ObservedEntryKey, ObservedEntry, ObservedEntryKey::Comparator> | 36 typedef std::map<ObservedEntryKey, ObservedEntry, ObservedEntryKey::Comparator> |
34 ObservedEntries; | 37 ObservedEntries; |
35 | 38 |
| 39 // Map of subscribers for notifications about an observed entry. |
| 40 typedef std::map<GURL, Subscriber> Subscribers; |
| 41 |
| 42 // Represents a subscriber for notification about an observed entry. There may |
| 43 // be up to one subscriber per origin for the same observed entry. |
| 44 struct Subscriber { |
| 45 Subscriber(); |
| 46 ~Subscriber(); |
| 47 |
| 48 // Origin of the subscriber. |
| 49 GURL origin; |
| 50 |
| 51 // Whether the subscriber should be restored after shutdown or not. |
| 52 bool persistent; |
| 53 }; |
| 54 |
36 // Represents an observed entry on a file system. | 55 // Represents an observed entry on a file system. |
37 struct ObservedEntry { | 56 struct ObservedEntry { |
38 ObservedEntry(); | 57 ObservedEntry(); |
39 ~ObservedEntry(); | 58 ~ObservedEntry(); |
40 | 59 |
| 60 // Map of subscribers for notifications of the observed entry. |
| 61 Subscribers subscribers; |
| 62 |
| 63 // Path of the observed entry. |
41 base::FilePath entry_path; | 64 base::FilePath entry_path; |
| 65 |
| 66 // Whether observing is recursive or not. |
42 bool recursive; | 67 bool recursive; |
| 68 |
| 69 // Tag of the last notification for this observed entry. May be empty if not |
| 70 // supported. |
43 std::string last_tag; | 71 std::string last_tag; |
44 }; | 72 }; |
45 | 73 |
46 } // namespace file_system_provider | 74 } // namespace file_system_provider |
47 } // namespace chromeos | 75 } // namespace chromeos |
48 | 76 |
49 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ | 77 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OBSERVED_ENTRY_H_ |
OLD | NEW |