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

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

Issue 149313003: Significantly cleans up the ImageWriter Operation class and subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removes self-reference that was causing the operation to not be deleted. Removes some extra loggin… 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 }
24 22
25 DestroyPartitionsOperation::~DestroyPartitionsOperation() {} 23 DestroyPartitionsOperation::~DestroyPartitionsOperation() {}
26 24
27 void DestroyPartitionsOperation::Start() { 25 void DestroyPartitionsOperation::Start() {
28 if (!temp_dir_.CreateUniqueTempDir()) { 26 Operation::Start();
29 Error(error::kTempDirError);
30 return;
31 }
32 27
33 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &image_path_)) { 28 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &image_path_)) {
34 Error(error::kTempFileError); 29 Error(error::kTempFileError);
35 return; 30 return;
36 } 31 }
37 32
38 scoped_ptr<char[]> buffer(new char[kPartitionTableSize]); 33 scoped_ptr<char[]> buffer(new char[kPartitionTableSize]);
39 memset(buffer.get(), 0, kPartitionTableSize); 34 memset(buffer.get(), 0, kPartitionTableSize);
40 35
41 if (file_util::WriteFile(image_path_, buffer.get(), kPartitionTableSize) != 36 if (file_util::WriteFile(image_path_, buffer.get(), kPartitionTableSize) !=
42 kPartitionTableSize) { 37 kPartitionTableSize) {
43 Error(error::kTempFileError); 38 Error(error::kTempFileError);
44 return; 39 return;
45 } 40 }
46 41
47 WriteStart(); 42 Write(base::Bind(&DestroyPartitionsOperation::Finish, this));
48 } 43 }
49 44
50 } // namespace image_writer 45 } // namespace image_writer
51 } // namespace extensions 46 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698