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

Unified Diff: chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h

Issue 2715493002: mediaview: Support watchers in ArcFileSystemOperationRunner. (Closed)
Patch Set: Rebased to ToT. Created 3 years, 10 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_file_system_operation_runner.h
diff --git a/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h b/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h
index 65dcf5d3db57c144fc29f44ef41788f02eb0933c..df369a2199225762fd421b72588e8257ee1898ef 100644
--- a/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h
+++ b/chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h
@@ -5,6 +5,9 @@
#ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_H_
#define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_H_
+#include <stdint.h>
+
+#include <map>
#include <memory>
#include <string>
#include <vector>
@@ -16,6 +19,8 @@
#include "components/arc/arc_service.h"
#include "components/arc/common/file_system.mojom.h"
#include "components/arc/instance_holder.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "storage/browser/fileapi/watcher_manager.h"
namespace arc {
@@ -44,6 +49,7 @@ namespace arc {
// All member functions must be called on the UI thread.
class ArcFileSystemOperationRunner
: public ArcService,
+ public mojom::FileSystemHost,
public ArcSessionManager::Observer,
public InstanceHolder<mojom::FileSystemInstance>::Observer {
public:
@@ -53,6 +59,10 @@ class ArcFileSystemOperationRunner
using GetDocumentCallback = mojom::FileSystemInstance::GetDocumentCallback;
using GetChildDocumentsCallback =
mojom::FileSystemInstance::GetChildDocumentsCallback;
+ using AddWatcherCallback = base::Callback<void(int64_t watcher_id)>;
Luis Héctor Chávez 2017/03/06 17:10:48 nit: maybe sort lexicographically? I couldn't find
+ using RemoveWatcherCallback = base::Callback<void(bool success)>;
+ using ChangeType = storage::WatcherManager::ChangeType;
+ using WatcherCallback = base::Callback<void(ChangeType type)>;
// For supporting ArcServiceManager::GetService<T>().
static const char kArcServiceName[];
@@ -79,6 +89,14 @@ class ArcFileSystemOperationRunner
void GetChildDocuments(const std::string& authority,
const std::string& parent_document_id,
const GetChildDocumentsCallback& callback);
+ void AddWatcher(const std::string& authority,
+ const std::string& document_id,
+ const WatcherCallback& watcher_callback,
+ const AddWatcherCallback& callback);
+ void RemoveWatcher(int64_t watcher_id, const RemoveWatcherCallback& callback);
+
+ // FileSystemHost overrides:
+ void OnDocumentChanged(int64_t watcher_id, mojom::ChangeType type) override;
// ArcSessionManager::Observer overrides:
void OnArcPlayStoreEnabledChanged(bool enabled) override;
@@ -92,7 +110,11 @@ class ArcFileSystemOperationRunner
ArcFileSystemOperationRunner(ArcBridgeService* bridge_service,
const Profile* profile,
- bool observe_events);
+ bool set_should_defer_by_events);
+
+ void OnWatcherAdded(const WatcherCallback& watcher_callback,
+ const AddWatcherCallback& callback,
+ int64_t watcher_id);
// Called whenever ARC states related to |should_defer_| are changed.
void OnStateChanged();
@@ -106,9 +128,9 @@ class ArcFileSystemOperationRunner
// unit tests.
const Profile* const profile_;
- // Indicates if this instance should register observers to receive events.
+ // Indicates if this instance should enable/disable deferring by events.
// Usually true, but set to false in unit tests.
- const bool observe_events_;
+ bool set_should_defer_by_events_;
// Set to true if operations should be deferred at this moment.
// The default is set to false so that operations are not deferred in
@@ -118,6 +140,11 @@ class ArcFileSystemOperationRunner
// List of deferred operations.
std::vector<base::Closure> deferred_operations_;
+ // Map from a watcher ID to a watcher callback.
+ std::map<int64_t, WatcherCallback> watcher_callbacks_;
+
+ mojo::Binding<mojom::FileSystemHost> binding_;
+
base::WeakPtrFactory<ArcFileSystemOperationRunner> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ArcFileSystemOperationRunner);

Powered by Google App Engine
This is Rietveld 408576698