Chromium Code Reviews| Index: webkit/fileapi/syncable/syncable_file_operation_runner.h |
| diff --git a/webkit/fileapi/syncable/syncable_file_operation_runner.h b/webkit/fileapi/syncable/syncable_file_operation_runner.h |
| index 95cf5c6809d59b93b38846857172396d91269ac1..c8d26b5fada9c3163407265e0ecd5652f0c3a562 100644 |
| --- a/webkit/fileapi/syncable/syncable_file_operation_runner.h |
| +++ b/webkit/fileapi/syncable/syncable_file_operation_runner.h |
| @@ -14,18 +14,19 @@ |
| #include "base/memory/weak_ptr.h" |
| #include "base/threading/non_thread_safe.h" |
| #include "webkit/fileapi/file_system_url.h" |
| +#include "webkit/fileapi/syncable/local_file_sync_status.h" |
| #include "webkit/storage/webkit_storage_export.h" |
| namespace fileapi { |
| class FileSystemURL; |
| -class LocalFileSyncStatus; |
| // This class must run only on IO thread. |
| // Owned by LocalFileSyncContext. |
| class WEBKIT_STORAGE_EXPORT SyncableFileOperationRunner |
| : public base::NonThreadSafe, |
| - public base::SupportsWeakPtr<SyncableFileOperationRunner> { |
| + public base::SupportsWeakPtr<SyncableFileOperationRunner>, |
| + public LocalFileSyncStatus::Observer { |
| public: |
| // Represents an operation task (which usually wraps one FileSystemOperation). |
| class Task { |
| @@ -50,15 +51,20 @@ class WEBKIT_STORAGE_EXPORT SyncableFileOperationRunner |
| DISALLOW_COPY_AND_ASSIGN(Task); |
| }; |
| - SyncableFileOperationRunner(); |
| - ~SyncableFileOperationRunner(); |
| + SyncableFileOperationRunner(size_t max_inflight_tasks, |
| + LocalFileSyncStatus* sync_status); |
| + virtual ~SyncableFileOperationRunner(); |
| + |
| + // LocalFileSyncStatus::Observer overrides. |
| + virtual void OnSyncEnabled(const FileSystemURL& url) OVERRIDE; |
| + virtual void OnWriteEnabled(const FileSystemURL& url) OVERRIDE; |
| // Runs the given |task| if no sync operation is running on any of |
| - // its target_paths(). This also runs pending operations that have become |
| + // its target_paths(). This also runs pending tasks that have become |
| // runnable (before running the given operation). |
| - // If there're ongoing sync operations on the target_paths this method |
| + // If there're ongoing sync tasks on the target_paths this method |
| // just queues up the |task|. |
| - // Pending operations are cancelled when this class is destructed. |
| + // Pending tasks are cancelled when this class is destructed. |
| void PostOperationTask(scoped_ptr<Task> task); |
| // Runs a next runnable task (if there's any). |
| @@ -68,14 +74,22 @@ class WEBKIT_STORAGE_EXPORT SyncableFileOperationRunner |
| // writable and may start a next runnable task. |
| void OnOperationCompleted(const std::vector<FileSystemURL>& target_paths); |
| - // For syncable file systems. |
| - LocalFileSyncStatus* sync_status() const { return sync_status_.get(); } |
| + LocalFileSyncStatus* sync_status() const { return sync_status_; } |
| + |
| + size_t num_pending_tasks() const { return pending_tasks_.size(); } |
|
tzik
2012/10/23 06:08:20
Could you s/size_t/int64/ and add static_cast?
kinuko
2012/10/23 07:54:03
Done.
|
| + size_t num_inflight_tasks() const { return num_inflight_tasks_; } |
| private: |
| - // Keeps track of the writing/syncing status. |
| - scoped_ptr<LocalFileSyncStatus> sync_status_; |
| + // Returns true if we should start more tasks. |
| + bool ShouldStartMoreTasks() const; |
| + |
| + // Keeps track of the writing/syncing status. Not owned. |
| + LocalFileSyncStatus* sync_status_; |
| + |
| + std::list<Task*> pending_tasks_; |
| - std::list<Task*> pending_operations_; |
| + const size_t max_inflight_tasks_; |
|
tzik
2012/10/23 06:08:20
ditto
kinuko
2012/10/23 07:54:03
Done.
|
| + size_t num_inflight_tasks_; |
| DISALLOW_COPY_AND_ASSIGN(SyncableFileOperationRunner); |
| }; |