| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/storage_monitor/image_capture_device.h" | 5 #import "chrome/browser/storage_monitor/image_capture_device.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 void RenameFile(const base::FilePath& downloaded_filename, | 12 void RenameFile(const base::FilePath& downloaded_filename, |
| 13 const base::FilePath& desired_filename, | 13 const base::FilePath& desired_filename, |
| 14 base::PlatformFileError* result) { | 14 base::PlatformFileError* result) { |
| 15 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 15 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 16 bool success = file_util::ReplaceFile(downloaded_filename, desired_filename); | 16 bool success = base::ReplaceFile(downloaded_filename, desired_filename, NULL); |
| 17 *result = success ? base::PLATFORM_FILE_OK | 17 *result = success ? base::PLATFORM_FILE_OK |
| 18 : base::PLATFORM_FILE_ERROR_NOT_FOUND; | 18 : base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 19 } | 19 } |
| 20 | 20 |
| 21 void ReturnRenameResultToListener( | 21 void ReturnRenameResultToListener( |
| 22 base::WeakPtr<ImageCaptureDeviceListener> listener, | 22 base::WeakPtr<ImageCaptureDeviceListener> listener, |
| 23 const std::string& name, | 23 const std::string& name, |
| 24 base::PlatformFileError* result) { | 24 base::PlatformFileError* result) { |
| 25 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 25 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 26 scoped_ptr<base::PlatformFileError> result_deleter(result); | 26 scoped_ptr<base::PlatformFileError> result_deleter(result); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Shared result value from file-copy closure to tell-listener closure. | 212 // Shared result value from file-copy closure to tell-listener closure. |
| 213 base::PlatformFileError* copyResult = new base::PlatformFileError(); | 213 base::PlatformFileError* copyResult = new base::PlatformFileError(); |
| 214 content::BrowserThread::PostTaskAndReply( | 214 content::BrowserThread::PostTaskAndReply( |
| 215 content::BrowserThread::FILE, | 215 content::BrowserThread::FILE, |
| 216 FROM_HERE, | 216 FROM_HERE, |
| 217 base::Bind(&RenameFile, savedPath, saveAsPath, copyResult), | 217 base::Bind(&RenameFile, savedPath, saveAsPath, copyResult), |
| 218 base::Bind(&ReturnRenameResultToListener, listener_, name, copyResult)); | 218 base::Bind(&ReturnRenameResultToListener, listener_, name, copyResult)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 @end // ImageCaptureDevice | 221 @end // ImageCaptureDevice |
| OLD | NEW |