Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation.cc

Issue 170123002: Revert of Significantly cleans up the ImageWriter Operation class and subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 8
9 namespace extensions { 9 namespace extensions {
10 namespace image_writer { 10 namespace image_writer {
11 11
12 // Number of bytes for the maximum partition table size. By wiping this many 12 // 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 13 // bytes we can essentially guarantee the header and associated information will
14 // be wiped. See http://crbug.com/328246 for more information. 14 // be wiped. See http://crbug.com/328246 for more information.
15 const int kPartitionTableSize = 1 * 1024; 15 const int kPartitionTableSize = 1 * 1024;
16 16
17 DestroyPartitionsOperation::DestroyPartitionsOperation( 17 DestroyPartitionsOperation::DestroyPartitionsOperation(
18 base::WeakPtr<OperationManager> manager, 18 base::WeakPtr<OperationManager> manager,
19 const ExtensionId& extension_id, 19 const ExtensionId& extension_id,
20 const std::string& storage_unit_id) 20 const std::string& storage_unit_id)
21 : Operation(manager, extension_id, storage_unit_id) {} 21 : Operation(manager, extension_id, storage_unit_id) {
22 verify_write_ = false;
23 }
22 24
23 DestroyPartitionsOperation::~DestroyPartitionsOperation() {} 25 DestroyPartitionsOperation::~DestroyPartitionsOperation() {}
24 26
25 void DestroyPartitionsOperation::StartImpl() { 27 void DestroyPartitionsOperation::Start() {
28 if (!temp_dir_.CreateUniqueTempDir()) {
29 Error(error::kTempDirError);
30 return;
31 }
32
26 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &image_path_)) { 33 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &image_path_)) {
27 Error(error::kTempFileError); 34 Error(error::kTempFileError);
28 return; 35 return;
29 } 36 }
30 37
31 scoped_ptr<char[]> buffer(new char[kPartitionTableSize]); 38 scoped_ptr<char[]> buffer(new char[kPartitionTableSize]);
32 memset(buffer.get(), 0, kPartitionTableSize); 39 memset(buffer.get(), 0, kPartitionTableSize);
33 40
34 if (file_util::WriteFile(image_path_, buffer.get(), kPartitionTableSize) != 41 if (file_util::WriteFile(image_path_, buffer.get(), kPartitionTableSize) !=
35 kPartitionTableSize) { 42 kPartitionTableSize) {
36 Error(error::kTempFileError); 43 Error(error::kTempFileError);
37 return; 44 return;
38 } 45 }
39 46
40 Write(base::Bind(&DestroyPartitionsOperation::Finish, this)); 47 WriteStart();
41 } 48 }
42 49
43 } // namespace image_writer 50 } // namespace image_writer
44 } // namespace extensions 51 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698