Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.cc

Issue 2709013003: mediaview: Implement ArcDocumentsProviderWatcherManager. (Closed)
Patch Set: Rebased to ToT. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_man ager.h"
6
7 #include "base/files/file.h"
8 #include "base/files/file_path.h"
9 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
10 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "storage/browser/fileapi/file_system_url.h"
13
14 using content::BrowserThread;
15 using storage::FileSystemURL;
16
17 namespace arc {
18
19 ArcDocumentsProviderWatcherManager::ArcDocumentsProviderWatcherManager(
20 ArcDocumentsProviderRootMap* roots)
21 : roots_(roots), weak_ptr_factory_(this) {}
22
23 ArcDocumentsProviderWatcherManager::~ArcDocumentsProviderWatcherManager() {
24 DCHECK_CURRENTLY_ON(BrowserThread::IO);
25 }
26
27 void ArcDocumentsProviderWatcherManager::AddWatcher(
28 const FileSystemURL& url,
29 bool recursive,
30 const StatusCallback& callback,
31 const NotificationCallback& notification_callback) {
32 DCHECK_CURRENTLY_ON(BrowserThread::IO);
33
34 if (recursive) {
35 // Recursive watching is not supported.
36 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
37 return;
38 }
39
40 base::FilePath path;
41 ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path);
42 if (!root) {
43 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
44 return;
45 }
46
47 root->AddWatcher(path, notification_callback, callback);
48 }
49
50 void ArcDocumentsProviderWatcherManager::RemoveWatcher(
51 const FileSystemURL& url,
52 bool recursive,
53 const StatusCallback& callback) {
54 DCHECK_CURRENTLY_ON(BrowserThread::IO);
55
56 if (recursive) {
57 // Recursive watching is not supported.
58 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
59 return;
60 }
61
62 base::FilePath path;
63 ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path);
64 if (!root) {
65 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
66 return;
67 }
68
69 root->RemoveWatcher(path, callback);
70 }
71
72 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698