| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_
operation.h" | 6 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_
operation.h" |
| 7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 8 | 9 |
| 9 namespace extensions { | 10 namespace extensions { |
| 10 namespace image_writer { | 11 namespace image_writer { |
| 11 | 12 |
| 12 // Number of bytes for the maximum partition table size. By wiping this many | 13 // Number of bytes for the maximum partition table size. By wiping this many |
| 13 // bytes we can essentially guarantee the header and associated information will | 14 // bytes we can essentially guarantee the header and associated information will |
| 14 // be wiped. See http://crbug.com/328246 for more information. | 15 // be wiped. See http://crbug.com/328246 for more information. |
| 15 const int kPartitionTableSize = 1 * 1024; | 16 const int kPartitionTableSize = 1 * 1024; |
| 16 | 17 |
| 17 DestroyPartitionsOperation::DestroyPartitionsOperation( | 18 DestroyPartitionsOperation::DestroyPartitionsOperation( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 scoped_ptr<char[]> buffer(new char[kPartitionTableSize]); | 39 scoped_ptr<char[]> buffer(new char[kPartitionTableSize]); |
| 39 memset(buffer.get(), 0, kPartitionTableSize); | 40 memset(buffer.get(), 0, kPartitionTableSize); |
| 40 | 41 |
| 41 if (file_util::WriteFile(image_path_, buffer.get(), kPartitionTableSize) != | 42 if (file_util::WriteFile(image_path_, buffer.get(), kPartitionTableSize) != |
| 42 kPartitionTableSize) { | 43 kPartitionTableSize) { |
| 43 Error(error::kTempFileError); | 44 Error(error::kTempFileError); |
| 44 return; | 45 return; |
| 45 } | 46 } |
| 46 | 47 |
| 47 WriteStart(); | 48 content::BrowserThread::PostTask( |
| 49 content::BrowserThread::FILE, |
| 50 FROM_HERE, |
| 51 base::Bind(&DestroyPartitionsOperation::WriteStart, this)); |
| 48 } | 52 } |
| 49 | 53 |
| 50 } // namespace image_writer | 54 } // namespace image_writer |
| 51 } // namespace extensions | 55 } // namespace extensions |
| OLD | NEW |