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

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

Issue 61643015: Adds imageWriterPrivate support for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorganization and test updates. Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/files/file_enumerator.h" 6 #include "base/files/file_enumerator.h"
7 #include "base/threading/worker_pool.h" 7 #include "base/threading/worker_pool.h"
8 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" 8 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
9 #include "chrome/browser/extensions/api/image_writer_private/operation.h" 9 #include "chrome/browser/extensions/api/image_writer_private/operation.h"
10 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h " 10 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h "
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "third_party/zlib/google/zip.h" 12 #include "third_party/zlib/google/zip.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 namespace image_writer { 15 namespace image_writer {
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 18
19 namespace { 19 namespace {
20 20
21 const int kMD5BufferSize = 1024; 21 const int kMD5BufferSize = 1024;
22 22
23 void RemoveTempDirectory(const base::FilePath path) { 23 void RemoveTempDirectory(const base::FilePath path) {
24 DVLOG(1) << "Removing temporary directory: " << path.value();
24 base::DeleteFile(path, true); 25 base::DeleteFile(path, true);
25 } 26 }
26 27
27 } // namespace 28 } // namespace
28 29
29 Operation::Operation(base::WeakPtr<OperationManager> manager, 30 Operation::Operation(base::WeakPtr<OperationManager> manager,
30 const ExtensionId& extension_id, 31 const ExtensionId& extension_id,
31 const std::string& storage_unit_id) 32 const std::string& storage_unit_id)
32 : manager_(manager), 33 : manager_(manager),
33 extension_id_(extension_id), 34 extension_id_(extension_id),
(...skipping 10 matching lines...) Expand all
44 45
45 stage_ = image_writer_api::STAGE_NONE; 46 stage_ = image_writer_api::STAGE_NONE;
46 47
47 CleanUp(); 48 CleanUp();
48 } 49 }
49 50
50 void Operation::Abort() { 51 void Operation::Abort() {
51 Error(error::kAborted); 52 Error(error::kAborted);
52 } 53 }
53 54
55 void Operation::OnWriteImageSucceeded() {
56 Finish();
57 }
58
59 void Operation::OnWriteImageFailed(const std::string& message) {
60 Error(message);
61 }
62
63 void Operation::OnWriteImageProgress(int progress) {
64 SetProgress(progress);
65 }
66
54 void Operation::Error(const std::string& error_message) { 67 void Operation::Error(const std::string& error_message) {
55 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { 68 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) {
56 BrowserThread::PostTask(BrowserThread::FILE, 69 BrowserThread::PostTask(BrowserThread::FILE,
57 FROM_HERE, 70 FROM_HERE,
58 base::Bind(&Operation::Error, this, error_message)); 71 base::Bind(&Operation::Error, this, error_message));
59 return; 72 return;
60 } 73 }
61 74
62 BrowserThread::PostTask( 75 BrowserThread::PostTask(
63 BrowserThread::UI, 76 BrowserThread::UI,
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 callback.Run(hash.Pass()); 324 callback.Run(hash.Pass());
312 } 325 }
313 } else { // len < 0 326 } else { // len < 0
314 reader->Close(); 327 reader->Close();
315 Error(error::kReadImage); 328 Error(error::kReadImage);
316 } 329 }
317 } 330 }
318 331
319 } // namespace image_writer 332 } // namespace image_writer
320 } // namespace extensions 333 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698