| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "content/browser/download/download_file.h" | 9 #include "content/browser/download/download_file.h" |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/browser/download/download_request_handle.h" | 15 #include "content/browser/download/download_request_handle.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 | 17 |
| 18 struct DownloadCreateInfo; | 18 struct DownloadCreateInfo; |
| 19 class DownloadManager; | 19 class DownloadManager; |
| 20 | 20 |
| 21 class CONTENT_EXPORT DownloadFileImpl : virtual public DownloadFile { | 21 class CONTENT_EXPORT DownloadFileImpl : virtual public DownloadFile { |
| 22 public: | 22 public: |
| 23 // Takes ownership of the object pointed to by |request_handle|. | 23 // Takes ownership of the object pointed to by |request_handle|. |
| 24 DownloadFileImpl(const DownloadCreateInfo* info, | 24 DownloadFileImpl(const DownloadCreateInfo* info, |
| 25 DownloadRequestHandleInterface* request_handle, | 25 DownloadRequestHandleInterface* request_handle, |
| 26 DownloadManager* download_manager); | 26 DownloadManager* download_manager, |
| 27 bool calculate_hash); |
| 27 virtual ~DownloadFileImpl(); | 28 virtual ~DownloadFileImpl(); |
| 28 | 29 |
| 29 // DownloadFile functions. | 30 // DownloadFile functions. |
| 30 virtual net::Error Initialize(bool calculate_hash) OVERRIDE; | 31 virtual net::Error Initialize() OVERRIDE; |
| 31 virtual net::Error AppendDataToFile(const char* data, | 32 virtual net::Error AppendDataToFile(const char* data, |
| 32 size_t data_len) OVERRIDE; | 33 size_t data_len) OVERRIDE; |
| 33 virtual net::Error Rename(const FilePath& full_path) OVERRIDE; | 34 virtual net::Error Rename(const FilePath& full_path) OVERRIDE; |
| 34 virtual void Detach() OVERRIDE; | 35 virtual void Detach() OVERRIDE; |
| 35 virtual void Cancel() OVERRIDE; | 36 virtual void Cancel() OVERRIDE; |
| 36 virtual void Finish() OVERRIDE; | 37 virtual void Finish() OVERRIDE; |
| 37 virtual void AnnotateWithSourceInformation() OVERRIDE; | 38 virtual void AnnotateWithSourceInformation() OVERRIDE; |
| 38 virtual FilePath FullPath() const OVERRIDE; | 39 virtual FilePath FullPath() const OVERRIDE; |
| 39 virtual bool InProgress() const OVERRIDE; | 40 virtual bool InProgress() const OVERRIDE; |
| 40 virtual int64 BytesSoFar() const OVERRIDE; | 41 virtual int64 BytesSoFar() const OVERRIDE; |
| 41 virtual int64 CurrentSpeed() const OVERRIDE; | 42 virtual int64 CurrentSpeed() const OVERRIDE; |
| 42 virtual bool GetSha256Hash(std::string* hash) OVERRIDE; | 43 virtual bool GetHash(std::string* hash) OVERRIDE; |
| 44 virtual std::string GetHashState() OVERRIDE; |
| 43 virtual void CancelDownloadRequest() OVERRIDE; | 45 virtual void CancelDownloadRequest() OVERRIDE; |
| 44 virtual int Id() const OVERRIDE; | 46 virtual int Id() const OVERRIDE; |
| 45 virtual DownloadManager* GetDownloadManager() OVERRIDE; | 47 virtual DownloadManager* GetDownloadManager() OVERRIDE; |
| 46 virtual const DownloadId& GlobalId() const OVERRIDE; | 48 virtual const DownloadId& GlobalId() const OVERRIDE; |
| 47 virtual std::string DebugString() const OVERRIDE; | 49 virtual std::string DebugString() const OVERRIDE; |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 // The base file instance. | 52 // The base file instance. |
| 51 BaseFile file_; | 53 BaseFile file_; |
| 52 | 54 |
| 53 // The unique identifier for this download, assigned at creation by | 55 // The unique identifier for this download, assigned at creation by |
| 54 // the DownloadFileManager for its internal record keeping. | 56 // the DownloadFileManager for its internal record keeping. |
| 55 DownloadId id_; | 57 DownloadId id_; |
| 56 | 58 |
| 57 // The handle to the request information. Used for operations outside the | 59 // The handle to the request information. Used for operations outside the |
| 58 // download system, specifically canceling a download. | 60 // download system, specifically canceling a download. |
| 59 scoped_ptr<DownloadRequestHandleInterface> request_handle_; | 61 scoped_ptr<DownloadRequestHandleInterface> request_handle_; |
| 60 | 62 |
| 61 // DownloadManager this download belongs to. | 63 // DownloadManager this download belongs to. |
| 62 scoped_refptr<DownloadManager> download_manager_; | 64 scoped_refptr<DownloadManager> download_manager_; |
| 63 | 65 |
| 64 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); | 66 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 69 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
| OLD | NEW |