#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_
#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MTP_DEVICE_ASYNC_DELEGATE_H_
#include "base/callback.h"
#include "base/files/file.h"
#include "base/memory/ref_counted.h"
#include "webkit/browser/fileapi/async_file_util.h"
namespace base {
class FilePath;
}
namespace net {
class IOBuffer;
}
class MTPDeviceAsyncDelegate {
public:
typedef base::Callback<
void(const base::File::Info& file_info)> GetFileInfoSuccessCallback;
typedef base::Callback<
void(const fileapi::AsyncFileUtil::EntryList& file_list,
bool has_more)> ReadDirectorySuccessCallback;
typedef base::Callback<void(base::File::Error error)> ErrorCallback;
typedef base::Callback<
void(const base::File::Info& file_info,
const base::FilePath& local_path)> CreateSnapshotFileSuccessCallback;
typedef base::Callback<
void(const base::File::Info& file_info,
int bytes_read)> ReadBytesSuccessCallback;
struct ReadBytesRequest {
ReadBytesRequest(const std::string& device_file_relative_path,
net::IOBuffer* buf, int64 offset, int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback);
~ReadBytesRequest();
std::string device_file_relative_path;
scoped_refptr<net::IOBuffer> buf;
int64 offset;
int buf_len;
ReadBytesSuccessCallback success_callback;
ErrorCallback error_callback;
};
virtual void GetFileInfo(
const base::FilePath& file_path,
const GetFileInfoSuccessCallback& success_callback,
const ErrorCallback& error_callback) = 0;
virtual void ReadDirectory(
const base::FilePath& root,
const ReadDirectorySuccessCallback& success_callback,
const ErrorCallback& error_callback) = 0;
virtual void CreateSnapshotFile(
const base::FilePath& device_file_path,
const base::FilePath& local_path,
const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) = 0;
virtual bool IsStreaming() = 0;
virtual void ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) = 0;
virtual void CancelPendingTasksAndDeleteDelegate() = 0;
protected:
virtual ~MTPDeviceAsyncDelegate() {}
};
typedef base::Callback<void(MTPDeviceAsyncDelegate*)>
CreateMTPDeviceAsyncDelegateCallback;
void CreateMTPDeviceAsyncDelegate(
const base::FilePath::StringType& device_location,
const CreateMTPDeviceAsyncDelegateCallback& callback);
#endif