Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / file_system_provider / fileapi / watcher_manager.cc
blob837d152adcf8fa61e72950f2a59e74ba3c8a6cb6
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;
14 namespace chromeos {
15 namespace file_system_provider {
17 WatcherManager::WatcherManager() {
19 WatcherManager::~WatcherManager() {
22 void WatcherManager::AddWatcher(
23 const storage::FileSystemURL& url,
24 bool recursive,
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);
32 return;
35 parser.file_system()->AddWatcher(url.origin(),
36 parser.file_path(),
37 recursive,
38 false /* persistent */,
39 callback,
40 notification_callback);
43 void WatcherManager::RemoveWatcher(const storage::FileSystemURL& url,
44 bool recursive,
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);
51 return;
54 parser.file_system()->RemoveWatcher(
55 url.origin(), parser.file_path(), recursive, callback);
58 } // namespace file_system_provider
59 } // namespace chromeos