| 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 #include "content/browser/download/base_file.h" | 5 #include "content/browser/download/base_file.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 SHFILEOPSTRUCT move_info = {0}; | 182 SHFILEOPSTRUCT move_info = {0}; |
| 183 move_info.wFunc = FO_MOVE; | 183 move_info.wFunc = FO_MOVE; |
| 184 move_info.pFrom = source.c_str(); | 184 move_info.pFrom = source.c_str(); |
| 185 move_info.pTo = target.c_str(); | 185 move_info.pTo = target.c_str(); |
| 186 move_info.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | | 186 move_info.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | |
| 187 FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS; | 187 FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS; |
| 188 | 188 |
| 189 int result = SHFileOperation(&move_info); | 189 int result = SHFileOperation(&move_info); |
| 190 | 190 |
| 191 if (result == 0) | 191 if (result == 0) |
| 192 return net::OK; | 192 return (move_info.fAnyOperationsAborted) ? net::ERR_ABORTED : net::OK; |
| 193 | 193 |
| 194 return MapShFileOperationCodes(result); | 194 return MapShFileOperationCodes(result); |
| 195 } | 195 } |
| 196 | 196 |
| 197 #endif | 197 #endif |
| 198 | 198 |
| 199 } // namespace | 199 } // namespace |
| 200 | 200 |
| 201 // This will initialize the entire array to zero. | 201 // This will initialize the entire array to zero. |
| 202 const unsigned char BaseFile::kEmptySha256Hash[] = { 0 }; | 202 const unsigned char BaseFile::kEmptySha256Hash[] = { 0 }; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { | 548 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { |
| 549 base::TimeDelta diff = current_time - start_tick_; | 549 base::TimeDelta diff = current_time - start_tick_; |
| 550 int64 diff_ms = diff.InMilliseconds(); | 550 int64 diff_ms = diff.InMilliseconds(); |
| 551 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; | 551 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; |
| 552 } | 552 } |
| 553 | 553 |
| 554 int64 BaseFile::CurrentSpeed() const { | 554 int64 BaseFile::CurrentSpeed() const { |
| 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 556 return CurrentSpeedAtTime(base::TimeTicks::Now()); | 556 return CurrentSpeedAtTime(base::TimeTicks::Now()); |
| 557 } | 557 } |
| OLD | NEW |