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