| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/ref_counted.h" | |
| 11 #include "chrome/browser/download/base_file.h" | 10 #include "chrome/browser/download/base_file.h" |
| 12 #include "chrome/browser/download/download_types.h" | 11 #include "chrome/browser/download/download_types.h" |
| 13 | 12 |
| 14 struct DownloadCreateInfo; | 13 struct DownloadCreateInfo; |
| 15 class DownloadManager; | |
| 16 class ResourceDispatcherHost; | 14 class ResourceDispatcherHost; |
| 17 | 15 |
| 18 // These objects live exclusively on the download thread and handle the writing | 16 // These objects live exclusively on the download thread and handle the writing |
| 19 // operations for one download. These objects live only for the duration that | 17 // operations for one download. These objects live only for the duration that |
| 20 // the download is 'in progress': once the download has been completed or | 18 // the download is 'in progress': once the download has been completed or |
| 21 // cancelled, the DownloadFile is destroyed. | 19 // cancelled, the DownloadFile is destroyed. |
| 22 class DownloadFile : public BaseFile { | 20 class DownloadFile : public BaseFile { |
| 23 public: | 21 public: |
| 24 DownloadFile(const DownloadCreateInfo* info, | 22 explicit DownloadFile(const DownloadCreateInfo* info); |
| 25 DownloadManager* download_manager); | |
| 26 virtual ~DownloadFile(); | 23 virtual ~DownloadFile(); |
| 27 | 24 |
| 28 // Deletes its .crdownload intermediate file. | 25 // Deletes its .crdownload intermediate file. |
| 29 // Marked virtual for testing. | 26 // Marked virtual for testing. |
| 30 virtual void DeleteCrDownload(); | 27 virtual void DeleteCrDownload(); |
| 31 | 28 |
| 32 // Cancels the download request associated with this file. | 29 // Cancels the download request associated with this file. |
| 33 void CancelDownloadRequest(ResourceDispatcherHost* rdh); | 30 void CancelDownloadRequest(ResourceDispatcherHost* rdh); |
| 34 | 31 |
| 35 void OnDownloadManagerShutdown(); | |
| 36 | |
| 37 int id() const { return id_; } | 32 int id() const { return id_; } |
| 38 DownloadManager* GetDownloadManager(); | |
| 39 | 33 |
| 40 private: | 34 private: |
| 41 // The unique identifier for this download, assigned at creation by | 35 // The unique identifier for this download, assigned at creation by |
| 42 // the DownloadFileManager for its internal record keeping. | 36 // the DownloadFileManager for its internal record keeping. |
| 43 int id_; | 37 int id_; |
| 44 | 38 |
| 45 // IDs for looking up the tab we are associated with. | 39 // IDs for looking up the tab we are associated with. |
| 46 int child_id_; | 40 int child_id_; |
| 47 | 41 |
| 48 // Handle for informing the ResourceDispatcherHost of a UI based cancel. | 42 // Handle for informing the ResourceDispatcherHost of a UI based cancel. |
| 49 int request_id_; | 43 int request_id_; |
| 50 | 44 |
| 51 // DownloadManager this download belongs to. | |
| 52 scoped_refptr<DownloadManager> download_manager_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(DownloadFile); | 45 DISALLOW_COPY_AND_ASSIGN(DownloadFile); |
| 55 }; | 46 }; |
| 56 | 47 |
| 57 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 48 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| OLD | NEW |