Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: content/browser/download/download_file_impl.h

Issue 18284005: Make ByteStream independent from DownloadInterruptReason (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rdsmith's comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "content/browser/byte_stream.h" 15 #include "content/browser/byte_stream.h"
16 #include "content/browser/download/base_file.h" 16 #include "content/browser/download/base_file.h"
17 #include "content/browser/download/rate_estimator.h" 17 #include "content/browser/download/rate_estimator.h"
18 #include "content/public/browser/download_interrupt_reasons.h"
18 #include "content/public/browser/download_save_info.h" 19 #include "content/public/browser/download_save_info.h"
19 #include "net/base/net_log.h" 20 #include "net/base/net_log.h"
20 21
21 namespace content { 22 namespace content {
23 template <typename StatusType>
22 class ByteStreamReader; 24 class ByteStreamReader;
23 class DownloadDestinationObserver; 25 class DownloadDestinationObserver;
24 class DownloadManager; 26 class DownloadManager;
25 class PowerSaveBlocker; 27 class PowerSaveBlocker;
26 struct DownloadCreateInfo; 28 struct DownloadCreateInfo;
27 29
28 class CONTENT_EXPORT DownloadFileImpl : virtual public DownloadFile { 30 class CONTENT_EXPORT DownloadFileImpl : virtual public DownloadFile {
29 public: 31 public:
30 // Takes ownership of the object pointed to by |request_handle|. 32 // Takes ownership of the object pointed to by |request_handle|.
31 // |bound_net_log| will be used for logging the download file's events. 33 // |bound_net_log| will be used for logging the download file's events.
32 // May be constructed on any thread. All methods besides the constructor 34 // May be constructed on any thread. All methods besides the constructor
33 // (including destruction) must occur on the FILE thread. 35 // (including destruction) must occur on the FILE thread.
34 // 36 //
35 // Note that the DownloadFileImpl automatically reads from the passed in 37 // Note that the DownloadFileImpl automatically reads from the passed in
36 // stream, and sends updates and status of those reads to the 38 // stream, and sends updates and status of those reads to the
37 // DownloadDestinationObserver. 39 // DownloadDestinationObserver.
38 DownloadFileImpl( 40 DownloadFileImpl(
39 scoped_ptr<DownloadSaveInfo> save_info, 41 scoped_ptr<DownloadSaveInfo> save_info,
40 const base::FilePath& default_downloads_directory, 42 const base::FilePath& default_downloads_directory,
41 const GURL& url, 43 const GURL& url,
42 const GURL& referrer_url, 44 const GURL& referrer_url,
43 bool calculate_hash, 45 bool calculate_hash,
44 scoped_ptr<ByteStreamReader> stream, 46 scoped_ptr<ByteStreamReader<DownloadInterruptReason> > stream,
45 const net::BoundNetLog& bound_net_log, 47 const net::BoundNetLog& bound_net_log,
46 scoped_ptr<PowerSaveBlocker> power_save_blocker, 48 scoped_ptr<PowerSaveBlocker> power_save_blocker,
47 base::WeakPtr<DownloadDestinationObserver> observer); 49 base::WeakPtr<DownloadDestinationObserver> observer);
48 50
49 virtual ~DownloadFileImpl(); 51 virtual ~DownloadFileImpl();
50 52
51 // DownloadFile functions. 53 // DownloadFile functions.
52 virtual void Initialize(const InitializeCallback& callback) OVERRIDE; 54 virtual void Initialize(const InitializeCallback& callback) OVERRIDE;
53 virtual void RenameAndUniquify( 55 virtual void RenameAndUniquify(
54 const base::FilePath& full_path, 56 const base::FilePath& full_path,
(...skipping 25 matching lines...) Expand all
80 // The base file instance. 82 // The base file instance.
81 BaseFile file_; 83 BaseFile file_;
82 84
83 // The default directory for creating the download file. 85 // The default directory for creating the download file.
84 base::FilePath default_download_directory_; 86 base::FilePath default_download_directory_;
85 87
86 // The stream through which data comes. 88 // The stream through which data comes.
87 // TODO(rdsmith): Move this into BaseFile; requires using the same 89 // TODO(rdsmith): Move this into BaseFile; requires using the same
88 // stream semantics in SavePackage. Alternatively, replace SaveFile 90 // stream semantics in SavePackage. Alternatively, replace SaveFile
89 // with DownloadFile and get rid of BaseFile. 91 // with DownloadFile and get rid of BaseFile.
90 scoped_ptr<ByteStreamReader> stream_reader_; 92 scoped_ptr<ByteStreamReader<DownloadInterruptReason> > stream_reader_;
91 93
92 // Used to trigger progress updates. 94 // Used to trigger progress updates.
93 scoped_ptr<base::RepeatingTimer<DownloadFileImpl> > update_timer_; 95 scoped_ptr<base::RepeatingTimer<DownloadFileImpl> > update_timer_;
94 96
95 // Statistics 97 // Statistics
96 size_t bytes_seen_; 98 size_t bytes_seen_;
97 base::TimeDelta disk_writes_time_; 99 base::TimeDelta disk_writes_time_;
98 base::TimeTicks download_start_; 100 base::TimeTicks download_start_;
99 RateEstimator rate_estimator_; 101 RateEstimator rate_estimator_;
100 102
101 net::BoundNetLog bound_net_log_; 103 net::BoundNetLog bound_net_log_;
102 104
103 base::WeakPtr<DownloadDestinationObserver> observer_; 105 base::WeakPtr<DownloadDestinationObserver> observer_;
104 106
105 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; 107 base::WeakPtrFactory<DownloadFileImpl> weak_factory_;
106 108
107 // RAII handle to keep the system from sleeping while we're downloading. 109 // RAII handle to keep the system from sleeping while we're downloading.
108 scoped_ptr<PowerSaveBlocker> power_save_blocker_; 110 scoped_ptr<PowerSaveBlocker> power_save_blocker_;
109 111
110 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); 112 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl);
111 }; 113 };
112 114
113 } // namespace content 115 } // namespace content
114 116
115 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ 117 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_file_factory.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698