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_
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "storage/browser/fileapi/watcher_manager.h"
18 namespace file_system_provider
{
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.
26 WatcherKey(const base::FilePath
& entry_path
, bool recursive
);
30 bool operator()(const WatcherKey
& a
, const WatcherKey
& b
) const;
33 base::FilePath entry_path
;
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.
49 // Origin of the subscriber.
52 // Whether the subscriber should be restored after shutdown or not.
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.
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.
76 // Tag of the last notification for this watcher. May be empty if not
81 } // namespace file_system_provider
82 } // namespace chromeos
84 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_WATCHER_H_