| 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 #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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 scoped_ptr<content::ByteStreamReader> stream, | 34 scoped_ptr<content::ByteStreamReader> stream, |
| 35 DownloadRequestHandleInterface* request_handle, | 35 DownloadRequestHandleInterface* request_handle, |
| 36 scoped_refptr<content::DownloadManager> download_manager, | 36 scoped_refptr<content::DownloadManager> download_manager, |
| 37 bool calculate_hash, | 37 bool calculate_hash, |
| 38 scoped_ptr<content::PowerSaveBlocker> power_save_blocker, | 38 scoped_ptr<content::PowerSaveBlocker> power_save_blocker, |
| 39 const net::BoundNetLog& bound_net_log); | 39 const net::BoundNetLog& bound_net_log); |
| 40 virtual ~DownloadFileImpl(); | 40 virtual ~DownloadFileImpl(); |
| 41 | 41 |
| 42 // DownloadFile functions. | 42 // DownloadFile functions. |
| 43 virtual content::DownloadInterruptReason Initialize() OVERRIDE; | 43 virtual content::DownloadInterruptReason Initialize() OVERRIDE; |
| 44 virtual content::DownloadInterruptReason Rename( | 44 virtual void Rename(const FilePath& full_path, |
| 45 const FilePath& full_path) OVERRIDE; | 45 bool overwrite_existing_file, |
| 46 const RenameCompletionCallback& callback) OVERRIDE; |
| 46 virtual void Detach() OVERRIDE; | 47 virtual void Detach() OVERRIDE; |
| 47 virtual void Cancel() OVERRIDE; | 48 virtual void Cancel() OVERRIDE; |
| 48 virtual void AnnotateWithSourceInformation() OVERRIDE; | 49 virtual void AnnotateWithSourceInformation() OVERRIDE; |
| 49 virtual FilePath FullPath() const OVERRIDE; | 50 virtual FilePath FullPath() const OVERRIDE; |
| 50 virtual bool InProgress() const OVERRIDE; | 51 virtual bool InProgress() const OVERRIDE; |
| 51 virtual int64 BytesSoFar() const OVERRIDE; | 52 virtual int64 BytesSoFar() const OVERRIDE; |
| 52 virtual int64 CurrentSpeed() const OVERRIDE; | 53 virtual int64 CurrentSpeed() const OVERRIDE; |
| 53 virtual bool GetHash(std::string* hash) OVERRIDE; | 54 virtual bool GetHash(std::string* hash) OVERRIDE; |
| 54 virtual std::string GetHashState() OVERRIDE; | 55 virtual std::string GetHashState() OVERRIDE; |
| 55 virtual void CancelDownloadRequest() OVERRIDE; | 56 virtual void CancelDownloadRequest() OVERRIDE; |
| 56 virtual int Id() const OVERRIDE; | 57 virtual int Id() const OVERRIDE; |
| 57 virtual content::DownloadManager* GetDownloadManager() OVERRIDE; | 58 virtual content::DownloadManager* GetDownloadManager() OVERRIDE; |
| 58 virtual const content::DownloadId& GlobalId() const OVERRIDE; | 59 virtual const content::DownloadId& GlobalId() const OVERRIDE; |
| 59 virtual std::string DebugString() const OVERRIDE; | 60 virtual std::string DebugString() const OVERRIDE; |
| 60 | 61 |
| 61 protected: | 62 protected: |
| 62 // For test class overrides. | 63 // For test class overrides. |
| 63 virtual content::DownloadInterruptReason AppendDataToFile( | 64 virtual content::DownloadInterruptReason AppendDataToFile( |
| 64 const char* data, size_t data_len); | 65 const char* data, size_t data_len); |
| 65 | 66 |
| 66 private: | 67 private: |
| 68 // Send an update on our progress. |
| 69 void SendUpdate(); |
| 70 |
| 67 // Called when there's some activity on stream_reader_ that needs to be | 71 // Called when there's some activity on stream_reader_ that needs to be |
| 68 // handled. | 72 // handled. |
| 69 void StreamActive(); | 73 void StreamActive(); |
| 70 | 74 |
| 71 // Send updates on our progress. | |
| 72 void SendUpdate(); | |
| 73 | |
| 74 // The base file instance. | 75 // The base file instance. |
| 75 BaseFile file_; | 76 BaseFile file_; |
| 76 | 77 |
| 77 // The stream through which data comes. | 78 // The stream through which data comes. |
| 78 // TODO(rdsmith): Move this into BaseFile; requires using the same | 79 // TODO(rdsmith): Move this into BaseFile; requires using the same |
| 79 // stream semantics in SavePackage. Alternatively, replace SaveFile | 80 // stream semantics in SavePackage. Alternatively, replace SaveFile |
| 80 // with DownloadFile and get rid of BaseFile. | 81 // with DownloadFile and get rid of BaseFile. |
| 81 scoped_ptr<content::ByteStreamReader> stream_reader_; | 82 scoped_ptr<content::ByteStreamReader> stream_reader_; |
| 82 | 83 |
| 83 // The unique identifier for this download, assigned at creation by | 84 // The unique identifier for this download, assigned at creation by |
| (...skipping 19 matching lines...) Expand all Loading... |
| 103 | 104 |
| 104 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; | 105 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; |
| 105 | 106 |
| 106 // RAII handle to keep the system from sleeping while we're downloading. | 107 // RAII handle to keep the system from sleeping while we're downloading. |
| 107 scoped_ptr<content::PowerSaveBlocker> power_save_blocker_; | 108 scoped_ptr<content::PowerSaveBlocker> power_save_blocker_; |
| 108 | 109 |
| 109 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); | 110 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 113 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
| OLD | NEW |