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

Side by Side Diff: content/public/browser/download_item.h

Issue 2703883003: Read and restore persisted slice info (Closed)
Patch Set: Created 3 years, 10 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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 // Called when the download is being destroyed. This happens after 96 // Called when the download is being destroyed. This happens after
97 // every OnDownloadRemoved() as well as when the DownloadManager is going 97 // every OnDownloadRemoved() as well as when the DownloadManager is going
98 // down. 98 // down.
99 virtual void OnDownloadDestroyed(DownloadItem* download) {} 99 virtual void OnDownloadDestroyed(DownloadItem* download) {}
100 100
101 protected: 101 protected:
102 virtual ~Observer() {} 102 virtual ~Observer() {}
103 }; 103 };
104 104
105 struct CONTENT_EXPORT ReceivedSlice {
106 ReceivedSlice(int64_t offset, int64_t received_bytes)
107 : offset(offset), received_bytes(received_bytes) {}
108
109 bool operator==(const ReceivedSlice& rhs) const {
110 return offset == rhs.offset && received_bytes == rhs.received_bytes;
111 }
112
113 int64_t offset;
114 int64_t received_bytes;
115 };
116
105 ~DownloadItem() override {} 117 ~DownloadItem() override {}
106 118
107 // Observation --------------------------------------------------------------- 119 // Observation ---------------------------------------------------------------
108 120
109 virtual void AddObserver(DownloadItem::Observer* observer) = 0; 121 virtual void AddObserver(DownloadItem::Observer* observer) = 0;
110 virtual void RemoveObserver(DownloadItem::Observer* observer) = 0; 122 virtual void RemoveObserver(DownloadItem::Observer* observer) = 0;
111 virtual void UpdateObservers() = 0; 123 virtual void UpdateObservers() = 0;
112 124
113 // User Actions -------------------------------------------------------------- 125 // User Actions --------------------------------------------------------------
114 126
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // final name. 354 // final name.
343 virtual bool AllDataSaved() const = 0; 355 virtual bool AllDataSaved() const = 0;
344 356
345 // Total number of expected bytes. Returns -1 if the total size is unknown. 357 // Total number of expected bytes. Returns -1 if the total size is unknown.
346 virtual int64_t GetTotalBytes() const = 0; 358 virtual int64_t GetTotalBytes() const = 0;
347 359
348 // Total number of bytes that have been received and written to the download 360 // Total number of bytes that have been received and written to the download
349 // file. 361 // file.
350 virtual int64_t GetReceivedBytes() const = 0; 362 virtual int64_t GetReceivedBytes() const = 0;
351 363
364 // Return the slices that have been received so far. This is only used
365 // when parallel downloading is enabled.
366 virtual const std::vector<ReceivedSlice>& GetReceivedSlices() const = 0;
367
352 // Time the download was first started. This timestamp is always valid and 368 // Time the download was first started. This timestamp is always valid and
353 // doesn't change. 369 // doesn't change.
354 virtual base::Time GetStartTime() const = 0; 370 virtual base::Time GetStartTime() const = 0;
355 371
356 // Time the download was marked as complete. Returns base::Time() if the 372 // Time the download was marked as complete. Returns base::Time() if the
357 // download hasn't reached a completion state yet. 373 // download hasn't reached a completion state yet.
358 virtual base::Time GetEndTime() const = 0; 374 virtual base::Time GetEndTime() const = 0;
359 375
360 // Open/Show State accessors ---------------------------------------------- 376 // Open/Show State accessors ----------------------------------------------
361 377
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // return |name|. Has no effect on the final target filename. 424 // return |name|. Has no effect on the final target filename.
409 virtual void SetDisplayName(const base::FilePath& name) = 0; 425 virtual void SetDisplayName(const base::FilePath& name) = 0;
410 426
411 // Debug/testing ------------------------------------------------------------- 427 // Debug/testing -------------------------------------------------------------
412 virtual std::string DebugString(bool verbose) const = 0; 428 virtual std::string DebugString(bool verbose) const = 0;
413 }; 429 };
414 430
415 } // namespace content 431 } // namespace content
416 432
417 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_ 433 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ITEM_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl_unittest.cc ('k') | content/public/browser/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698