summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authormtomasz <mtomasz@chromium.org>2014-08-27 22:37:34 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-28 05:38:33 +0000
commitb75244fdf1d75e67485649e6a96a69c50676bbc3 (patch)
tree447e6d0b48e058ac28e5374dc9532bf4237f9302 /webkit
parenteacf155f2d41b79a64c9b4eca997e62ebc77b8cb (diff)
downloadchromium_src-b75244fdf1d75e67485649e6a96a69c50676bbc3.zip
chromium_src-b75244fdf1d75e67485649e6a96a69c50676bbc3.tar.gz
chromium_src-b75244fdf1d75e67485649e6a96a69c50676bbc3.tar.bz2
[ew] Add basic classes.
This patch adds a EntryWatcherService, which is a bridge between extensions and fileapi. Also, WatcherManager interface has been created to let backends implement their own watching logic. Note, that EntryWatcherService is not wired up to File System API yet. Also, a lot of features are missing. TBR=noamsml, jcivelli TEST=unit_tests: *EntryWatcherService* BUG=261491 Review URL: https://codereview.chromium.org/452043003 Cr-Commit-Position: refs/heads/master@{#292327}
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/file_system_backend.h6
-rw-r--r--webkit/browser/fileapi/file_system_context.cc8
-rw-r--r--webkit/browser/fileapi/file_system_context.h5
-rw-r--r--webkit/browser/fileapi/isolated_file_system_backend.cc6
-rw-r--r--webkit/browser/fileapi/isolated_file_system_backend.h1
-rw-r--r--webkit/browser/fileapi/plugin_private_file_system_backend.cc5
-rw-r--r--webkit/browser/fileapi/plugin_private_file_system_backend.h2
-rw-r--r--webkit/browser/fileapi/sandbox_file_system_backend.cc5
-rw-r--r--webkit/browser/fileapi/sandbox_file_system_backend.h1
-rw-r--r--webkit/browser/fileapi/watcher_manager.h67
10 files changed, 106 insertions, 0 deletions
diff --git a/webkit/browser/fileapi/file_system_backend.h b/webkit/browser/fileapi/file_system_backend.h
index 9853745..7f0220d 100644
--- a/webkit/browser/fileapi/file_system_backend.h
+++ b/webkit/browser/fileapi/file_system_backend.h
@@ -33,6 +33,7 @@ class FileSystemContext;
class FileSystemFileUtil;
class FileSystemOperation;
class FileSystemQuotaUtil;
+class WatcherManager;
// An interface for defining a file system backend.
//
@@ -70,6 +71,9 @@ class STORAGE_EXPORT FileSystemBackend {
// Returns the specialized AsyncFileUtil for this backend.
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) = 0;
+ // Returns the specialized WatcherManager for this backend.
+ virtual WatcherManager* GetWatcherManager(FileSystemType type) = 0;
+
// Returns the specialized CopyOrMoveFileValidatorFactory for this backend
// and |type|. If |error_code| is File::FILE_OK and the result is NULL,
// then no validator is required.
@@ -105,6 +109,8 @@ class STORAGE_EXPORT FileSystemBackend {
// ERR_UPLOAD_FILE_CHANGED error.
// This method itself does *not* check if the given path exists and is a
// regular file.
+ // The |length| argument says how many bytes are going to be read using the
+ // instance of the file stream reader. If unknown, then equal to -1.
virtual scoped_ptr<storage::FileStreamReader> CreateFileStreamReader(
const FileSystemURL& url,
int64 offset,
diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc
index 5d44499..cb62556 100644
--- a/webkit/browser/fileapi/file_system_context.cc
+++ b/webkit/browser/fileapi/file_system_context.cc
@@ -277,6 +277,14 @@ FileSystemBackend* FileSystemContext::GetFileSystemBackend(
return NULL;
}
+WatcherManager* FileSystemContext::GetWatcherManager(
+ FileSystemType type) const {
+ FileSystemBackend* backend = GetFileSystemBackend(type);
+ if (!backend)
+ return NULL;
+ return backend->GetWatcherManager(type);
+}
+
bool FileSystemContext::IsSandboxFileSystem(FileSystemType type) const {
FileSystemBackendMap::const_iterator found = backend_map_.find(type);
return found != backend_map_.end() && found->second->GetQuotaUtil();
diff --git a/webkit/browser/fileapi/file_system_context.h b/webkit/browser/fileapi/file_system_context.h
index f8b9b52..d9c1c45 100644
--- a/webkit/browser/fileapi/file_system_context.h
+++ b/webkit/browser/fileapi/file_system_context.h
@@ -65,6 +65,7 @@ class IsolatedFileSystemBackend;
class MountPoints;
class QuotaReservation;
class SandboxFileSystemBackend;
+class WatchManager;
struct DefaultContextDeleter;
struct FileSystemInfo;
@@ -163,6 +164,10 @@ class STORAGE_EXPORT FileSystemContext
FileSystemBackend* GetFileSystemBackend(
FileSystemType type) const;
+ // Returns the watcher manager for the given |type|.
+ // This may return NULL if the type does not support watching.
+ WatcherManager* GetWatcherManager(FileSystemType type) const;
+
// Returns true for sandboxed filesystems. Currently this does
// the same as GetQuotaUtil(type) != NULL. (In an assumption that
// all sandboxed filesystems must cooperate with QuotaManager so that
diff --git a/webkit/browser/fileapi/isolated_file_system_backend.cc b/webkit/browser/fileapi/isolated_file_system_backend.cc
index b2aee2b..1b5f346 100644
--- a/webkit/browser/fileapi/isolated_file_system_backend.cc
+++ b/webkit/browser/fileapi/isolated_file_system_backend.cc
@@ -23,6 +23,7 @@
#include "webkit/browser/fileapi/isolated_context.h"
#include "webkit/browser/fileapi/native_file_util.h"
#include "webkit/browser/fileapi/transient_file_util.h"
+#include "webkit/browser/fileapi/watcher_manager.h"
#include "webkit/common/fileapi/file_system_types.h"
#include "webkit/common/fileapi/file_system_util.h"
@@ -84,6 +85,11 @@ AsyncFileUtil* IsolatedFileSystemBackend::GetAsyncFileUtil(
return NULL;
}
+WatcherManager* IsolatedFileSystemBackend::GetWatcherManager(
+ FileSystemType type) {
+ return NULL;
+}
+
CopyOrMoveFileValidatorFactory*
IsolatedFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
FileSystemType type, base::File::Error* error_code) {
diff --git a/webkit/browser/fileapi/isolated_file_system_backend.h b/webkit/browser/fileapi/isolated_file_system_backend.h
index a64b0b7..b252845 100644
--- a/webkit/browser/fileapi/isolated_file_system_backend.h
+++ b/webkit/browser/fileapi/isolated_file_system_backend.h
@@ -24,6 +24,7 @@ class IsolatedFileSystemBackend : public FileSystemBackend {
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) OVERRIDE;
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
+ virtual WatcherManager* GetWatcherManager(FileSystemType type) OVERRIDE;
virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
base::File::Error* error_code) OVERRIDE;
diff --git a/webkit/browser/fileapi/plugin_private_file_system_backend.cc b/webkit/browser/fileapi/plugin_private_file_system_backend.cc
index 7beb1b7..0a3cbf9 100644
--- a/webkit/browser/fileapi/plugin_private_file_system_backend.cc
+++ b/webkit/browser/fileapi/plugin_private_file_system_backend.cc
@@ -160,6 +160,11 @@ PluginPrivateFileSystemBackend::GetAsyncFileUtil(FileSystemType type) {
return file_util_.get();
}
+WatcherManager* PluginPrivateFileSystemBackend::GetWatcherManager(
+ FileSystemType type) {
+ return NULL;
+}
+
CopyOrMoveFileValidatorFactory*
PluginPrivateFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
diff --git a/webkit/browser/fileapi/plugin_private_file_system_backend.h b/webkit/browser/fileapi/plugin_private_file_system_backend.h
index 9ebc471..bd95bc9 100644
--- a/webkit/browser/fileapi/plugin_private_file_system_backend.h
+++ b/webkit/browser/fileapi/plugin_private_file_system_backend.h
@@ -29,6 +29,7 @@ class SpecialStoragePolicy;
namespace storage {
class ObfuscatedFileUtil;
+class WatcherManager;
class STORAGE_EXPORT PluginPrivateFileSystemBackend
: public FileSystemBackend,
@@ -65,6 +66,7 @@ class STORAGE_EXPORT PluginPrivateFileSystemBackend
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) OVERRIDE;
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
+ virtual WatcherManager* GetWatcherManager(FileSystemType type) OVERRIDE;
virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
base::File::Error* error_code) OVERRIDE;
diff --git a/webkit/browser/fileapi/sandbox_file_system_backend.cc b/webkit/browser/fileapi/sandbox_file_system_backend.cc
index a0ab15d..4aa9595 100644
--- a/webkit/browser/fileapi/sandbox_file_system_backend.cc
+++ b/webkit/browser/fileapi/sandbox_file_system_backend.cc
@@ -85,6 +85,11 @@ AsyncFileUtil* SandboxFileSystemBackend::GetAsyncFileUtil(
return delegate_->file_util();
}
+WatcherManager* SandboxFileSystemBackend::GetWatcherManager(
+ FileSystemType type) {
+ return NULL;
+}
+
CopyOrMoveFileValidatorFactory*
SandboxFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
diff --git a/webkit/browser/fileapi/sandbox_file_system_backend.h b/webkit/browser/fileapi/sandbox_file_system_backend.h
index 98743d2..7a60d4f 100644
--- a/webkit/browser/fileapi/sandbox_file_system_backend.h
+++ b/webkit/browser/fileapi/sandbox_file_system_backend.h
@@ -38,6 +38,7 @@ class STORAGE_EXPORT SandboxFileSystemBackend
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) OVERRIDE;
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
+ virtual WatcherManager* GetWatcherManager(FileSystemType type) OVERRIDE;
virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
base::File::Error* error_code) OVERRIDE;
diff --git a/webkit/browser/fileapi/watcher_manager.h b/webkit/browser/fileapi/watcher_manager.h
new file mode 100644
index 0000000..83a64f6
--- /dev/null
+++ b/webkit/browser/fileapi/watcher_manager.h
@@ -0,0 +1,67 @@
+// Copyright 2014 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.
+
+#ifndef WEBKIT_BROWSER_FILEAPI_WATCHER_MANAGER_H_
+#define WEBKIT_BROWSER_FILEAPI_WATCHER_MANAGER_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "base/files/file.h"
+
+namespace base {
+class Time;
+}
+
+namespace storage {
+
+class FileSystemOperationContext;
+class FileSystemURL;
+
+// An interface for providing entry observing capability for file system
+// backends.
+//
+// It is NOT valid to give null callback to this class, and implementors
+// can assume that they don't get any null callbacks.
+class WatcherManager {
+ public:
+ typedef base::Callback<void(base::File::Error result)> StatusCallback;
+
+ // Observes watched entries.
+ class Observer {
+ public:
+ Observer() {}
+ virtual ~Observer() {}
+
+ // Notifies about an entry represented by |url| being changed.
+ virtual void OnEntryChanged(const FileSystemURL& url) = 0;
+
+ // Notifies about an entry represented by |url| being removed.
+ virtual void OnEntryRemoved(const FileSystemURL& url) = 0;
+ };
+
+ virtual ~WatcherManager() {}
+
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+ virtual bool HasObserver(Observer* observer) const = 0;
+
+ // Observes a directory entry. If the |recursive| mode is not supported then
+ // FILE_ERROR_INVALID_OPERATION must be returned as an error. If the |url| is
+ // already watched, or setting up the watcher fails, then |callback|
+ // must be called with a specific error code. Otherwise |callback| must be
+ // called with the FILE_OK error code.
+ virtual void WatchDirectory(const FileSystemURL& url,
+ bool recursive,
+ const StatusCallback& callback) = 0;
+
+ // Stops observing an entry represented by |url|.
+ virtual void UnwatchEntry(const FileSystemURL& url,
+ const StatusCallback& callback) = 0;
+};
+
+} // namespace storage
+
+#endif // WEBKIT_BROWSER_FILEAPI_WATCHER_MANAGER_H_