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 <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
| 13 #include "base/files/file.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
19 #include "content/browser/byte_stream.h" | 20 #include "content/browser/byte_stream.h" |
20 #include "content/browser/download/base_file.h" | 21 #include "content/browser/download/base_file.h" |
21 #include "content/browser/download/rate_estimator.h" | 22 #include "content/browser/download/rate_estimator.h" |
22 #include "content/public/browser/download_save_info.h" | 23 #include "content/public/browser/download_save_info.h" |
23 #include "net/log/net_log.h" | 24 #include "net/log/net_log.h" |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 class ByteStreamReader; | 27 class ByteStreamReader; |
27 class DownloadDestinationObserver; | 28 class DownloadDestinationObserver; |
28 class DownloadManager; | 29 class DownloadManager; |
29 struct DownloadCreateInfo; | 30 struct DownloadCreateInfo; |
30 | 31 |
31 class CONTENT_EXPORT DownloadFileImpl : public DownloadFile { | 32 class CONTENT_EXPORT DownloadFileImpl : public DownloadFile { |
32 public: | 33 public: |
33 // Takes ownership of the object pointed to by |request_handle|. | 34 // Takes ownership of the object pointed to by |request_handle|. |
34 // |bound_net_log| will be used for logging the download file's events. | 35 // |bound_net_log| will be used for logging the download file's events. |
35 // May be constructed on any thread. All methods besides the constructor | 36 // May be constructed on any thread. All methods besides the constructor |
36 // (including destruction) must occur on the FILE thread. | 37 // (including destruction) must occur on the FILE thread. |
37 // | 38 // |
38 // Note that the DownloadFileImpl automatically reads from the passed in | 39 // Note that the DownloadFileImpl automatically reads from the passed in |
39 // stream, and sends updates and status of those reads to the | 40 // stream, and sends updates and status of those reads to the |
40 // DownloadDestinationObserver. | 41 // DownloadDestinationObserver. |
41 DownloadFileImpl( | 42 DownloadFileImpl(const DownloadSaveInfo& save_info, |
42 scoped_ptr<DownloadSaveInfo> save_info, | 43 const base::FilePath& default_downloads_directory, |
43 const base::FilePath& default_downloads_directory, | 44 const GURL& url, |
44 const GURL& url, | 45 const GURL& referrer_url, |
45 const GURL& referrer_url, | 46 bool calculate_hash, |
46 bool calculate_hash, | 47 base::File file, |
47 scoped_ptr<ByteStreamReader> stream, | 48 scoped_ptr<ByteStreamReader> byte_stream, |
48 const net::BoundNetLog& bound_net_log, | 49 const net::BoundNetLog& bound_net_log, |
49 base::WeakPtr<DownloadDestinationObserver> observer); | 50 base::WeakPtr<DownloadDestinationObserver> observer); |
50 | 51 |
51 ~DownloadFileImpl() override; | 52 ~DownloadFileImpl() override; |
52 | 53 |
53 // DownloadFile functions. | 54 // DownloadFile functions. |
54 void Initialize(const InitializeCallback& callback) override; | 55 void Initialize(const InitializeCallback& callback) override; |
55 void RenameAndUniquify(const base::FilePath& full_path, | 56 void RenameAndUniquify(const base::FilePath& full_path, |
56 const RenameCompletionCallback& callback) override; | 57 const RenameCompletionCallback& callback) override; |
57 void RenameAndAnnotate(const base::FilePath& full_path, | 58 void RenameAndAnnotate(const base::FilePath& full_path, |
58 const RenameCompletionCallback& callback) override; | 59 const RenameCompletionCallback& callback) override; |
59 void Detach() override; | 60 void Detach() override; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 base::WeakPtr<DownloadDestinationObserver> observer_; | 134 base::WeakPtr<DownloadDestinationObserver> observer_; |
134 | 135 |
135 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; | 136 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; |
136 | 137 |
137 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); | 138 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); |
138 }; | 139 }; |
139 | 140 |
140 } // namespace content | 141 } // namespace content |
141 | 142 |
142 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 143 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
OLD | NEW |