This source file includes following definitions.
- StartImpl
#include "base/file_util.h"
#include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation.h"
#include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
#include "content/public/browser/browser_thread.h"
namespace extensions {
namespace image_writer {
const int kPartitionTableSize = 1 * 1024;
DestroyPartitionsOperation::DestroyPartitionsOperation(
base::WeakPtr<OperationManager> manager,
const ExtensionId& extension_id,
const std::string& storage_unit_id)
: Operation(manager, extension_id, storage_unit_id) {}
DestroyPartitionsOperation::~DestroyPartitionsOperation() {}
void DestroyPartitionsOperation::StartImpl() {
if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &image_path_)) {
Error(error::kTempFileError);
return;
}
scoped_ptr<char[]> buffer(new char[kPartitionTableSize]);
memset(buffer.get(), 0, kPartitionTableSize);
if (base::WriteFile(image_path_, buffer.get(), kPartitionTableSize) !=
kPartitionTableSize) {
Error(error::kTempFileError);
return;
}
content::BrowserThread::PostTask(
content::BrowserThread::FILE,
FROM_HERE,
base::Bind(&DestroyPartitionsOperation::Write,
this,
base::Bind(&DestroyPartitionsOperation::Finish, this)));
}
}
}