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

Unified Diff: chrome/browser/chromeos/drive/sync_client.h

Issue 391343002: Keep sync tasks alive as long as it's not finished (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/drive/sync_client.h
diff --git a/chrome/browser/chromeos/drive/sync_client.h b/chrome/browser/chromeos/drive/sync_client.h
index a8f6d1b3a57ba8d7bec1b6afb0fd00e5375072e2..3aab63f02a8776f09aeb9cb2a8151b760b27bdc4 100644
--- a/chrome/browser/chromeos/drive/sync_client.h
+++ b/chrome/browser/chromeos/drive/sync_client.h
@@ -14,6 +14,7 @@
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/chromeos/drive/file_errors.h"
+#include "chrome/browser/chromeos/drive/job_scheduler.h"
#include "chrome/browser/chromeos/drive/resource_metadata.h"
namespace base {
@@ -93,25 +94,38 @@ class SyncClient {
// States of sync tasks.
enum SyncState {
- PENDING,
- RUNNING,
+ SUSPENDED, // Task is currently inactive.
+ PENDING, // Task is going to run.
+ RUNNING, // Task is running.
};
+ typedef std::pair<SyncType, std::string> SyncTaskKey;
+
struct SyncTask {
SyncTask();
~SyncTask();
SyncState state;
- base::Callback<base::Closure()> task;
+ ClientContext context;
+ base::Callback<base::Closure(const ClientContext& context)> task;
bool should_run_again;
base::Closure cancel_closure;
+ std::vector<SyncTaskKey> dependent_tasks;
};
- typedef std::map<std::pair<SyncType, std::string>, SyncTask> SyncTasks;
+ typedef std::map<SyncTaskKey, SyncTask> SyncTasks;
+
+ // Performs a FETCH task.
+ base::Closure PerformFetchTask(const std::string& local_id,
+ const ClientContext& context);
// Adds a FETCH task.
void AddFetchTaskInternal(const std::string& local_id,
const base::TimeDelta& delay);
+ // Performs a UPDATE task.
+ base::Closure PerformUpdateTask(const std::string& local_id,
+ const ClientContext& context);
+
// Adds a UPDATE task.
void AddUpdateTaskInternal(const ClientContext& context,
const std::string& local_id,
@@ -132,8 +146,10 @@ class SyncClient {
// Adds fetch tasks.
void AddFetchTasks(const std::vector<std::string>* local_ids);
- // Erases the task and returns true if task is completed.
- bool OnTaskComplete(SyncType type, const std::string& local_id);
+ // Called when a task is completed.
+ void OnTaskComplete(SyncType type,
+ const std::string& local_id,
+ FileError error);
// Called when the file for |local_id| is fetched.
void OnFetchFileComplete(const std::string& local_id,
@@ -141,12 +157,11 @@ class SyncClient {
const base::FilePath& local_path,
scoped_ptr<ResourceEntry> entry);
- // Called when the entry is updated.
- void OnUpdateComplete(const std::string& local_id, FileError error);
-
- // Adds update tasks for |entries|.
- void AddChildUpdateTasks(const ResourceEntryVector* entries,
- FileError error);
+ // Adds the task as a dependent task of the parent entry's task.
+ void AddDependentTask(SyncType type,
+ const std::string& local_id,
+ const ResourceEntry* entry,
+ FileError error);
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
file_system::OperationObserver* operation_observer_;

Powered by Google App Engine
This is Rietveld 408576698