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

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

Issue 2715493002: mediaview: Support watchers in ArcFileSystemOperationRunner. (Closed)
Patch Set: Review ready. 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 958e46254a3e4a949b55a9432ff0a3b9013899ae..1016febddd67380a8192325e662220b26f9d0bf3 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)>;
+ 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[];
@@ -78,6 +88,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;
@@ -90,7 +108,11 @@ class ArcFileSystemOperationRunner
friend class ArcFileSystemOperationRunnerTest;
ArcFileSystemOperationRunner(ArcBridgeService* bridge_service,
- bool observe_events);
+ bool set_should_defer_by_events);
+
+ void AddWatcherDone(const WatcherCallback& watcher_callback,
hidehiko 2017/02/23 11:55:28 Optional: OnWatcherAdded to be consistent with "On
Shuhei Takahashi 2017/02/24 06:10:39 Done.
+ const AddWatcherCallback& callback,
+ int64_t watcher_id);
// Called whenever ARC states related to |should_defer_| are changed.
void OnStateChanged();
@@ -100,9 +122,9 @@ class ArcFileSystemOperationRunner
// deferring.
void SetShouldDefer(bool should_defer);
- // 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.
- 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
@@ -112,6 +134,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