OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_
operation.h" | 8 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_
operation.h" |
9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 : Operation(manager, extension_id, storage_unit_id) {} | 24 : Operation(manager, extension_id, storage_unit_id) {} |
25 | 25 |
26 DestroyPartitionsOperation::~DestroyPartitionsOperation() {} | 26 DestroyPartitionsOperation::~DestroyPartitionsOperation() {} |
27 | 27 |
28 void DestroyPartitionsOperation::StartImpl() { | 28 void DestroyPartitionsOperation::StartImpl() { |
29 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &image_path_)) { | 29 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &image_path_)) { |
30 Error(error::kTempFileError); | 30 Error(error::kTempFileError); |
31 return; | 31 return; |
32 } | 32 } |
33 | 33 |
34 scoped_ptr<char[]> buffer(new char[kPartitionTableSize]); | 34 std::unique_ptr<char[]> buffer(new char[kPartitionTableSize]); |
35 memset(buffer.get(), 0, kPartitionTableSize); | 35 memset(buffer.get(), 0, kPartitionTableSize); |
36 | 36 |
37 if (base::WriteFile(image_path_, buffer.get(), kPartitionTableSize) != | 37 if (base::WriteFile(image_path_, buffer.get(), kPartitionTableSize) != |
38 kPartitionTableSize) { | 38 kPartitionTableSize) { |
39 Error(error::kTempFileError); | 39 Error(error::kTempFileError); |
40 return; | 40 return; |
41 } | 41 } |
42 | 42 |
43 content::BrowserThread::PostTask( | 43 content::BrowserThread::PostTask( |
44 content::BrowserThread::FILE, | 44 content::BrowserThread::FILE, |
45 FROM_HERE, | 45 FROM_HERE, |
46 base::Bind(&DestroyPartitionsOperation::Write, | 46 base::Bind(&DestroyPartitionsOperation::Write, |
47 this, | 47 this, |
48 base::Bind(&DestroyPartitionsOperation::Finish, this))); | 48 base::Bind(&DestroyPartitionsOperation::Finish, this))); |
49 } | 49 } |
50 | 50 |
51 } // namespace image_writer | 51 } // namespace image_writer |
52 } // namespace extensions | 52 } // namespace extensions |
OLD | NEW |