12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_ROW_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_HISTORY_DOWNLOAD_ROW_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include <string>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <vector>
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
12eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/download_danger_type.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/download_interrupt_reasons.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/download_item.h"
16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace history {
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Contains the information that is stored in the download system's persistent
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// store (or refers to it). DownloadHistory uses this to communicate with the
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// DownloadDatabase through the HistoryService.
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct DownloadRow {
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DownloadRow();
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DownloadRow(
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::FilePath& current_path,
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::FilePath& target_path,
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::vector<GURL>& url_chain,
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const GURL& referrer,
30f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      const std::string& mime_type,
31f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      const std::string& original_mime_type,
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::Time& start,
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::Time& end,
34ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch      const std::string& etag,
35ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch      const std::string& last_modified,
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      int64 received,
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      int64 total,
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      content::DownloadItem::DownloadState download_state,
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      content::DownloadDangerType danger_type,
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      content::DownloadInterruptReason interrupt_reason,
417dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch      uint32 id,
42a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      bool download_opened,
43a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      const std::string& ext_id,
44a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)      const std::string& ext_name);
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ~DownloadRow();
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The current path to the download (potentially different from final if
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // download is in progress or interrupted).
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath current_path;
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The target path where the download will go when it's complete.
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::FilePath target_path;
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The URL redirect chain through which we are downloading.  The front
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // is the url that the initial request went to, and the back is the
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // url from which we ended up getting data.  This is not changed by
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // UpdateDownload().
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  std::vector<GURL> url_chain;
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The URL that referred us. Is not changed by UpdateDownload().
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GURL referrer_url;
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
63f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // The MIME type of the download, might be based on heuristics.
64f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  std::string mime_type;
65f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
66f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // The original MIME type of the download.
67f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  std::string original_mime_type;
68f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The time when the download started. Is not changed by UpdateDownload().
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::Time start_time;
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The time when the download completed.
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::Time end_time;
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
75ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  // Contents of most recently seen ETag header.
76ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  std::string etag;
77ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch
78ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  // Contents of most recently seen Last-Modified header.
79ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch  std::string last_modified;
80ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The number of bytes received (so far).
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int64 received_bytes;
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The total number of bytes in the download. Is not changed by
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // UpdateDownload().
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int64 total_bytes;
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The current state of the download.
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::DownloadItem::DownloadState state;
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Whether and how the download is dangerous.
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::DownloadDangerType danger_type;
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The reason the download was interrupted, if
952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // state == DownloadItem::INTERRUPTED
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::DownloadInterruptReason interrupt_reason;
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
987dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // The id of the download in the database. Is not changed by UpdateDownload().
997dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  uint32 id;
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Whether this download has ever been opened from the browser.
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool opened;
103a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
104a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // The id and name of the extension that created this download.
105a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  std::string by_ext_id;
106a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  std::string by_ext_name;
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace history
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CHROME_BROWSER_HISTORY_DOWNLOAD_ROW_H_
112