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 #include "chrome/browser/chromeos/file_system_provider/fileapi/watcher_manager.h"
7 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h"
8 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "storage/browser/fileapi/file_system_url.h"
12 using content::BrowserThread
;
15 namespace file_system_provider
{
17 WatcherManager::WatcherManager() {
19 WatcherManager::~WatcherManager() {
22 void WatcherManager::AddWatcher(
23 const storage::FileSystemURL
& url
,
25 const StatusCallback
& callback
,
26 const NotificationCallback
& notification_callback
) {
27 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
29 util::FileSystemURLParser
parser(url
);
30 if (!parser
.Parse()) {
31 callback
.Run(base::File::FILE_ERROR_SECURITY
);
35 parser
.file_system()->AddWatcher(url
.origin(),
38 false /* persistent */,
40 notification_callback
);
43 void WatcherManager::RemoveWatcher(const storage::FileSystemURL
& url
,
45 const StatusCallback
& callback
) {
46 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
48 util::FileSystemURLParser
parser(url
);
49 if (!parser
.Parse()) {
50 callback
.Run(base::File::FILE_ERROR_SECURITY
);
54 parser
.file_system()->RemoveWatcher(
55 url
.origin(), parser
.file_path(), recursive
, callback
);
58 } // namespace file_system_provider
59 } // namespace chromeos