Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / file_system_provider / watcher.h
blob2964c97cad5b2e6f7b42bb4044b3d26325e2c1f2
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_CHROMEOS_FILE_SYSTEM_PROVIDER_WATCHER_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_WATCHER_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "storage/browser/fileapi/watcher_manager.h"
15 #include "url/gurl.h"
17 namespace chromeos {
18 namespace file_system_provider {
20 struct Watcher;
21 struct Subscriber;
23 // Key for storing a watcher in the map. There may be two watchers per path,
24 // as long as one is recursive, and the other one not.
25 struct WatcherKey {
26 WatcherKey(const base::FilePath& entry_path, bool recursive);
27 ~WatcherKey();
29 struct Comparator {
30 bool operator()(const WatcherKey& a, const WatcherKey& b) const;
33 base::FilePath entry_path;
34 bool recursive;
37 // List of watchers.
38 typedef std::map<WatcherKey, Watcher, WatcherKey::Comparator> Watchers;
40 // Map of subscribers for notifications about a watcher.
41 typedef std::map<GURL, Subscriber> Subscribers;
43 // Represents a subscriber for notification about a watcher. There may be up to
44 // one subscriber per origin for the same watcher.
45 struct Subscriber {
46 Subscriber();
47 ~Subscriber();
49 // Origin of the subscriber.
50 GURL origin;
52 // Whether the subscriber should be restored after shutdown or not.
53 bool persistent;
55 // Callback to be called for each watcher notification. It's optional, but
56 // not allowed for persistent watchers. In case of persistent subscribers,
57 // the notification should be handled using observers, as the callback can't
58 // be restored after shutdown.
59 storage::WatcherManager::NotificationCallback notification_callback;
62 // Represents a watcher on a file system.
63 struct Watcher {
64 Watcher();
65 ~Watcher();
67 // Map of subscribers for notifications of the watcher.
68 Subscribers subscribers;
70 // Path of the watcher.
71 base::FilePath entry_path;
73 // Whether watching is recursive or not.
74 bool recursive;
76 // Tag of the last notification for this watcher. May be empty if not
77 // supported.
78 std::string last_tag;
81 } // namespace file_system_provider
82 } // namespace chromeos
84 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_WATCHER_H_