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

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

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Address Gabs comments, detach DownloadItemImpl and BaseFile from sequence at construction. Created 3 years, 6 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
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 <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include <memory> 13 #include <memory>
14 #include <string> 14 #include <string>
15 #include <unordered_map> 15 #include <unordered_map>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/files/file.h" 18 #include "base/files/file.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/threading/thread_checker.h" 22 #include "base/sequence_checker.h"
23 #include "base/time/time.h" 23 #include "base/time/time.h"
24 #include "base/timer/timer.h" 24 #include "base/timer/timer.h"
25 #include "content/browser/byte_stream.h" 25 #include "content/browser/byte_stream.h"
26 #include "content/browser/download/base_file.h" 26 #include "content/browser/download/base_file.h"
27 #include "content/browser/download/rate_estimator.h" 27 #include "content/browser/download/rate_estimator.h"
28 #include "content/public/browser/download_item.h" 28 #include "content/public/browser/download_item.h"
29 #include "content/public/browser/download_save_info.h" 29 #include "content/public/browser/download_save_info.h"
30 #include "net/log/net_log_with_source.h" 30 #include "net/log/net_log_with_source.h"
31 31
32 namespace content { 32 namespace content {
33 class ByteStreamReader; 33 class ByteStreamReader;
34 class DownloadDestinationObserver; 34 class DownloadDestinationObserver;
35 35
36 class CONTENT_EXPORT DownloadFileImpl : public DownloadFile { 36 class CONTENT_EXPORT DownloadFileImpl : public DownloadFile {
37 public: 37 public:
38 // Takes ownership of the object pointed to by |request_handle|. 38 // Takes ownership of the object pointed to by |request_handle|.
39 // |net_log| will be used for logging the download file's events. 39 // |net_log| will be used for logging the download file's events.
40 // May be constructed on any thread. All methods besides the constructor 40 // May be constructed on any thread. All methods besides the constructor
41 // (including destruction) must occur on the FILE thread. 41 // (including destruction) must occur on the download task runner.
fdoray 2017/06/22 13:01:35 s/download task runner/same sequence/ ? Since you'
Sigurður Ásgeirsson 2017/06/22 14:50:11 Done.
42 // 42 //
43 // Note that the DownloadFileImpl automatically reads from the passed in 43 // Note that the DownloadFileImpl automatically reads from the passed in
44 // stream, and sends updates and status of those reads to the 44 // stream, and sends updates and status of those reads to the
45 // DownloadDestinationObserver. 45 // DownloadDestinationObserver.
46 DownloadFileImpl( 46 DownloadFileImpl(std::unique_ptr<DownloadSaveInfo> save_info,
47 std::unique_ptr<DownloadSaveInfo> save_info, 47 const base::FilePath& default_downloads_directory,
48 const base::FilePath& default_downloads_directory, 48 std::unique_ptr<ByteStreamReader> stream_reader,
49 std::unique_ptr<ByteStreamReader> stream_reader, 49 const net::NetLogWithSource& net_log,
50 const net::NetLogWithSource& net_log, 50 base::WeakPtr<DownloadDestinationObserver> observer);
51 base::WeakPtr<DownloadDestinationObserver> observer);
52 51
53 ~DownloadFileImpl() override; 52 ~DownloadFileImpl() override;
54 53
55 // DownloadFile functions. 54 // DownloadFile functions.
56 void Initialize(const InitializeCallback& initialize_callback, 55 void Initialize(const InitializeCallback& initialize_callback,
57 const CancelRequestCallback& cancel_request_callback, 56 const CancelRequestCallback& cancel_request_callback,
58 const DownloadItem::ReceivedSlices& received_slices, 57 const DownloadItem::ReceivedSlices& received_slices,
59 bool is_parallelizable) override; 58 bool is_parallelizable) override;
60 59
61 void AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader, 60 void AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 int num_active_streams_; 271 int num_active_streams_;
273 bool record_stream_bandwidth_; 272 bool record_stream_bandwidth_;
274 base::TimeTicks last_update_time_; 273 base::TimeTicks last_update_time_;
275 size_t bytes_seen_with_parallel_streams_; 274 size_t bytes_seen_with_parallel_streams_;
276 size_t bytes_seen_without_parallel_streams_; 275 size_t bytes_seen_without_parallel_streams_;
277 base::TimeDelta download_time_with_parallel_streams_; 276 base::TimeDelta download_time_with_parallel_streams_;
278 base::TimeDelta download_time_without_parallel_streams_; 277 base::TimeDelta download_time_without_parallel_streams_;
279 278
280 std::vector<DownloadItem::ReceivedSlice> received_slices_; 279 std::vector<DownloadItem::ReceivedSlice> received_slices_;
281 280
281 SEQUENCE_CHECKER(sequence_checker_);
282
282 base::WeakPtr<DownloadDestinationObserver> observer_; 283 base::WeakPtr<DownloadDestinationObserver> observer_;
283 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; 284 base::WeakPtrFactory<DownloadFileImpl> weak_factory_;
284 285
285 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); 286 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl);
286 }; 287 };
287 288
288 } // namespace content 289 } // namespace content
289 290
290 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ 291 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698