#ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_
#define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_TOKEN_H_
#include "base/callback.h"
#include "base/location.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/sync_file_system/sync_callbacks.h"
namespace sync_file_system {
namespace drive_backend {
class SyncTaskManager;
struct BlockingFactor;
class SyncTaskToken {
public:
static const int64 kForegroundTaskTokenID;
static const int64 kMinimumBackgroundTaskTokenID;
static scoped_ptr<SyncTaskToken> CreateForForegroundTask(
const base::WeakPtr<SyncTaskManager>& manager);
static scoped_ptr<SyncTaskToken> CreateForBackgroundTask(
const base::WeakPtr<SyncTaskManager>& manager,
int64 token_id,
scoped_ptr<BlockingFactor> blocking_factor);
void UpdateTask(const tracked_objects::Location& location,
const SyncStatusCallback& callback);
const tracked_objects::Location& location() const { return location_; }
virtual ~SyncTaskToken();
static SyncStatusCallback WrapToCallback(scoped_ptr<SyncTaskToken> token);
SyncTaskManager* manager() { return manager_.get(); }
const SyncStatusCallback& callback() const { return callback_; }
void clear_callback() { callback_.Reset(); }
const BlockingFactor* blocking_factor() const;
void clear_blocking_factor();
int64 token_id() const { return token_id_; }
private:
SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager,
int64 token_id,
scoped_ptr<BlockingFactor> blocking_factor);
base::WeakPtr<SyncTaskManager> manager_;
tracked_objects::Location location_;
int64 token_id_;
SyncStatusCallback callback_;
scoped_ptr<BlockingFactor> blocking_factor_;
DISALLOW_COPY_AND_ASSIGN(SyncTaskToken);
};
}
}
#endif