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