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

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

Issue 216513002: Replace DCHECK(BrowserThread::CurrentlyOn) with DCHECK_CURRENTLY_ON in extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 "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 12
13 namespace extensions { 13 namespace extensions {
14 namespace image_writer { 14 namespace image_writer {
15 15
16 using content::BrowserThread; 16 using content::BrowserThread;
17 17
18 void Operation::Write(const base::Closure& continuation) { 18 void Operation::Write(const base::Closure& continuation) {
19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 19 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
20 if (IsCancelled()) { 20 if (IsCancelled()) {
21 return; 21 return;
22 } 22 }
23 23
24 SetStage(image_writer_api::STAGE_WRITE); 24 SetStage(image_writer_api::STAGE_WRITE);
25 StartUtilityClient(); 25 StartUtilityClient();
26 26
27 int64 file_size; 27 int64 file_size;
28 if (!base::GetFileSize(image_path_, &file_size)) { 28 if (!base::GetFileSize(image_path_, &file_size)) {
29 Error(error::kImageReadError); 29 Error(error::kImageReadError);
30 return; 30 return;
31 } 31 }
32 32
33 BrowserThread::PostTask( 33 BrowserThread::PostTask(
34 BrowserThread::IO, 34 BrowserThread::IO,
35 FROM_HERE, 35 FROM_HERE,
36 base::Bind( 36 base::Bind(
37 &ImageWriterUtilityClient::Write, 37 &ImageWriterUtilityClient::Write,
38 image_writer_client_, 38 image_writer_client_,
39 base::Bind(&Operation::WriteImageProgress, this, file_size), 39 base::Bind(&Operation::WriteImageProgress, this, file_size),
40 base::Bind(&Operation::CompleteAndContinue, this, continuation), 40 base::Bind(&Operation::CompleteAndContinue, this, continuation),
41 base::Bind(&Operation::Error, this), 41 base::Bind(&Operation::Error, this),
42 image_path_, 42 image_path_,
43 device_path_)); 43 device_path_));
44 } 44 }
45 45
46 void Operation::VerifyWrite(const base::Closure& continuation) { 46 void Operation::VerifyWrite(const base::Closure& continuation) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 47 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
48 48
49 if (IsCancelled()) { 49 if (IsCancelled()) {
50 return; 50 return;
51 } 51 }
52 52
53 SetStage(image_writer_api::STAGE_VERIFYWRITE); 53 SetStage(image_writer_api::STAGE_VERIFYWRITE);
54 StartUtilityClient(); 54 StartUtilityClient();
55 55
56 int64 file_size; 56 int64 file_size;
57 if (!base::GetFileSize(image_path_, &file_size)) { 57 if (!base::GetFileSize(image_path_, &file_size)) {
58 Error(error::kImageReadError); 58 Error(error::kImageReadError);
59 return; 59 return;
60 } 60 }
61 61
62 BrowserThread::PostTask( 62 BrowserThread::PostTask(
63 BrowserThread::IO, 63 BrowserThread::IO,
64 FROM_HERE, 64 FROM_HERE,
65 base::Bind( 65 base::Bind(
66 &ImageWriterUtilityClient::Verify, 66 &ImageWriterUtilityClient::Verify,
67 image_writer_client_, 67 image_writer_client_,
68 base::Bind(&Operation::WriteImageProgress, this, file_size), 68 base::Bind(&Operation::WriteImageProgress, this, file_size),
69 base::Bind(&Operation::CompleteAndContinue, this, continuation), 69 base::Bind(&Operation::CompleteAndContinue, this, continuation),
70 base::Bind(&Operation::Error, this), 70 base::Bind(&Operation::Error, this),
71 image_path_, 71 image_path_,
72 device_path_)); 72 device_path_));
73 } 73 }
74 74
75 } // namespace image_writer 75 } // namespace image_writer
76 } // namespace extensions 76 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698