OLD | NEW |
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 "chrome/browser/extensions/api/image_writer_private/operation.h" | 5 #include "chrome/browser/extensions/api/image_writer_private/operation.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 void Operation::CompleteAndContinue(const base::Closure& continuation) { | 243 void Operation::CompleteAndContinue(const base::Closure& continuation) { |
244 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 244 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
245 SetProgress(kProgressComplete); | 245 SetProgress(kProgressComplete); |
246 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation); | 246 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation); |
247 } | 247 } |
248 | 248 |
249 #if !defined(OS_CHROMEOS) | 249 #if !defined(OS_CHROMEOS) |
250 void Operation::StartUtilityClient() { | 250 void Operation::StartUtilityClient() { |
251 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 251 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
252 if (g_utility_client.Get()) { | 252 if (g_utility_client.Get().get()) { |
253 image_writer_client_ = g_utility_client.Get(); | 253 image_writer_client_ = g_utility_client.Get(); |
254 return; | 254 return; |
255 } | 255 } |
256 if (!image_writer_client_) { | 256 if (!image_writer_client_.get()) { |
257 image_writer_client_ = new ImageWriterUtilityClient(); | 257 image_writer_client_ = new ImageWriterUtilityClient(); |
258 AddCleanUpFunction(base::Bind(&Operation::StopUtilityClient, this)); | 258 AddCleanUpFunction(base::Bind(&Operation::StopUtilityClient, this)); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 void Operation::StopUtilityClient() { | 262 void Operation::StopUtilityClient() { |
263 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 263 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
264 BrowserThread::PostTask( | 264 BrowserThread::PostTask( |
265 BrowserThread::IO, | 265 BrowserThread::IO, |
266 FROM_HERE, | 266 FROM_HERE, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 for (std::vector<base::Closure>::iterator it = cleanup_functions_.begin(); | 387 for (std::vector<base::Closure>::iterator it = cleanup_functions_.begin(); |
388 it != cleanup_functions_.end(); | 388 it != cleanup_functions_.end(); |
389 ++it) { | 389 ++it) { |
390 it->Run(); | 390 it->Run(); |
391 } | 391 } |
392 cleanup_functions_.clear(); | 392 cleanup_functions_.clear(); |
393 } | 393 } |
394 | 394 |
395 } // namespace image_writer | 395 } // namespace image_writer |
396 } // namespace extensions | 396 } // namespace extensions |
OLD | NEW |