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

Unified Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.cc

Issue 2736613002: mediaview: Implement ArcDocumentsProviderWatcherManager. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.cc
diff --git a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.cc b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a81fbb9d191a8e5554f368f750d3dfb6515c8d8d
--- /dev/null
+++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.cc
@@ -0,0 +1,72 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.h"
+
+#include "base/files/file.h"
+#include "base/files/file_path.h"
+#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
+#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h"
+#include "content/public/browser/browser_thread.h"
+#include "storage/browser/fileapi/file_system_url.h"
+
+using content::BrowserThread;
+using storage::FileSystemURL;
+
+namespace arc {
+
+ArcDocumentsProviderWatcherManager::ArcDocumentsProviderWatcherManager(
+ ArcDocumentsProviderRootMap* roots)
+ : roots_(roots), weak_ptr_factory_(this) {}
+
+ArcDocumentsProviderWatcherManager::~ArcDocumentsProviderWatcherManager() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
+void ArcDocumentsProviderWatcherManager::AddWatcher(
+ const FileSystemURL& url,
+ bool recursive,
+ const StatusCallback& callback,
+ const NotificationCallback& notification_callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (recursive) {
+ // Recursive watching is not supported.
+ callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
+ return;
+ }
+
+ base::FilePath path;
+ ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path);
+ if (!root) {
+ callback.Run(base::File::FILE_ERROR_NOT_FOUND);
+ return;
+ }
+
+ root->AddWatcher(path, notification_callback, callback);
+}
+
+void ArcDocumentsProviderWatcherManager::RemoveWatcher(
+ const FileSystemURL& url,
+ bool recursive,
+ const StatusCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (recursive) {
+ // Recursive watching is not supported.
+ callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
+ return;
+ }
+
+ base::FilePath path;
+ ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path);
+ if (!root) {
+ callback.Run(base::File::FILE_ERROR_NOT_FOUND);
+ return;
+ }
+
+ root->RemoveWatcher(path, callback);
+}
+
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698