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

Unified Diff: webkit/fileapi/syncable/syncable_file_operation_runner.h

Issue 11238054: Add OnSyncEnabled/OnWriteEnabled notification handling to operation runner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added export Created 8 years, 2 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: 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..cd631384817a6dfec3bc2da052b151773b899cbf 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(int64 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,25 @@ 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_; }
+
+ int64 num_pending_tasks() const {
+ return static_cast<int64>(pending_tasks_.size());
+ }
+
+ int64 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 int64 max_inflight_tasks_;
+ int64 num_inflight_tasks_;
DISALLOW_COPY_AND_ASSIGN(SyncableFileOperationRunner);
};
« no previous file with comments | « webkit/fileapi/syncable/local_file_sync_status.cc ('k') | webkit/fileapi/syncable/syncable_file_operation_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698