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

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

Issue 2314363002: extensions: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Comment addressed Created 4 years, 3 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 <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"
11 11
12 namespace extensions { 12 namespace extensions {
13 namespace image_writer { 13 namespace image_writer {
14 14
15 // Number of bytes for the maximum partition table size. GUID partition tables 15 // Number of bytes for the maximum partition table size. GUID partition tables
16 // reside in the second sector of the disk. Disks can have up to 4k sectors. 16 // reside in the second sector of the disk. Disks can have up to 4k sectors.
17 // See http://crbug.com/328246 for more information. 17 // See http://crbug.com/328246 for more information.
18 const int kPartitionTableSize = 2 * 4096; 18 const int kPartitionTableSize = 2 * 4096;
19 19
20 DestroyPartitionsOperation::DestroyPartitionsOperation( 20 DestroyPartitionsOperation::DestroyPartitionsOperation(
21 base::WeakPtr<OperationManager> manager, 21 base::WeakPtr<OperationManager> manager,
22 const ExtensionId& extension_id, 22 const ExtensionId& extension_id,
23 const std::string& storage_unit_id) 23 const std::string& storage_unit_id)
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_.GetPath(), &image_path_)) {
30 Error(error::kTempFileError); 30 Error(error::kTempFileError);
31 return; 31 return;
32 } 32 }
33 33
34 std::unique_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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/i18n/i18n_apitest.cc ('k') | chrome/browser/extensions/api/image_writer_private/operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698