| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <Windows.h> | 5 #include <Windows.h> |
| 6 #include <objbase.h> | 6 #include <objbase.h> |
| 7 | 7 |
| 8 #include "chrome/browser/download/download_file.h" | 8 #include "chrome/browser/download/download_file.h" |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/download/download_manager.h" | 16 #include "chrome/browser/download/download_manager.h" |
| 17 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 18 #include "chrome/browser/resource_dispatcher_host.h" | 18 #include "chrome/browser/resource_dispatcher_host.h" |
| 19 #include "chrome/browser/tab_contents.h" | 19 #include "chrome/browser/tab_contents.h" |
| 20 #include "chrome/browser/tab_util.h" | 20 #include "chrome/browser/tab_util.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/stl_util-inl.h" | 22 #include "chrome/common/stl_util-inl.h" |
| 23 #include "chrome/common/win_util.h" | 23 #include "chrome/common/win_util.h" |
| 24 #include "chrome/common/win_safe_util.h" | 24 #include "chrome/common/win_safe_util.h" |
| 25 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 26 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
| 27 #include "net/url_request/url_request_context.h" | 27 #include "net/url_request/url_request_context.h" |
| 28 | 28 |
| 29 using base::TimeDelta; |
| 30 |
| 29 // Throttle updates to the UI thread so that a fast moving download doesn't | 31 // Throttle updates to the UI thread so that a fast moving download doesn't |
| 30 // cause it to become unresponsive (ins milliseconds). | 32 // cause it to become unresponsive (ins milliseconds). |
| 31 static const int kUpdatePeriodMs = 500; | 33 static const int kUpdatePeriodMs = 500; |
| 32 | 34 |
| 33 // Timer task for posting UI updates. This task is created and maintained by | 35 // Timer task for posting UI updates. This task is created and maintained by |
| 34 // the DownloadFileManager long as there is an in progress download. The task | 36 // the DownloadFileManager long as there is an in progress download. The task |
| 35 // is cancelled when all active downloads have completed, or in the destructor | 37 // is cancelled when all active downloads have completed, or in the destructor |
| 36 // of the DownloadFileManager. | 38 // of the DownloadFileManager. |
| 37 class DownloadFileUpdateTask : public Task { | 39 class DownloadFileUpdateTask : public Task { |
| 38 public: | 40 public: |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 void DownloadFileManager::CreateDirectory(const std::wstring& directory) { | 579 void DownloadFileManager::CreateDirectory(const std::wstring& directory) { |
| 578 if (!file_util::PathExists(directory)) | 580 if (!file_util::PathExists(directory)) |
| 579 file_util::CreateDirectory(directory); | 581 file_util::CreateDirectory(directory); |
| 580 } | 582 } |
| 581 | 583 |
| 582 void DownloadFileManager::DeleteFile(const std::wstring& path) { | 584 void DownloadFileManager::DeleteFile(const std::wstring& path) { |
| 583 // Make sure we only delete files. | 585 // Make sure we only delete files. |
| 584 if (file_util::PathExists(path) && !file_util::DirectoryExists(path)) | 586 if (file_util::PathExists(path) && !file_util::DirectoryExists(path)) |
| 585 file_util::Delete(path, false); | 587 file_util::Delete(path, false); |
| 586 } | 588 } |
| OLD | NEW |