Home | History | Annotate | Download | only in history
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_ROW_H_
      6 #define CHROME_BROWSER_HISTORY_DOWNLOAD_ROW_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/files/file_path.h"
     11 #include "base/time/time.h"
     12 #include "content/public/browser/download_danger_type.h"
     13 #include "content/public/browser/download_interrupt_reasons.h"
     14 #include "content/public/browser/download_item.h"
     15 #include "url/gurl.h"
     16 
     17 namespace history {
     18 
     19 // Contains the information that is stored in the download system's persistent
     20 // store (or refers to it). DownloadHistory uses this to communicate with the
     21 // DownloadDatabase through the HistoryService.
     22 struct DownloadRow {
     23   DownloadRow();
     24   DownloadRow(
     25       const base::FilePath& current_path,
     26       const base::FilePath& target_path,
     27       const std::vector<GURL>& url_chain,
     28       const GURL& referrer,
     29       const base::Time& start,
     30       const base::Time& end,
     31       const std::string& etag,
     32       const std::string& last_modified,
     33       int64 received,
     34       int64 total,
     35       content::DownloadItem::DownloadState download_state,
     36       content::DownloadDangerType danger_type,
     37       content::DownloadInterruptReason interrupt_reason,
     38       uint32 id,
     39       bool download_opened,
     40       const std::string& ext_id,
     41       const std::string& ext_name);
     42   ~DownloadRow();
     43 
     44   // The current path to the download (potentially different from final if
     45   // download is in progress or interrupted).
     46   base::FilePath current_path;
     47 
     48   // The target path where the download will go when it's complete.
     49   base::FilePath target_path;
     50 
     51   // The URL redirect chain through which we are downloading.  The front
     52   // is the url that the initial request went to, and the back is the
     53   // url from which we ended up getting data.  This is not changed by
     54   // UpdateDownload().
     55   std::vector<GURL> url_chain;
     56 
     57   // The URL that referred us. Is not changed by UpdateDownload().
     58   GURL referrer_url;
     59 
     60   // The time when the download started. Is not changed by UpdateDownload().
     61   base::Time start_time;
     62 
     63   // The time when the download completed.
     64   base::Time end_time;
     65 
     66   // Contents of most recently seen ETag header.
     67   std::string etag;
     68 
     69   // Contents of most recently seen Last-Modified header.
     70   std::string last_modified;
     71 
     72   // The number of bytes received (so far).
     73   int64 received_bytes;
     74 
     75   // The total number of bytes in the download. Is not changed by
     76   // UpdateDownload().
     77   int64 total_bytes;
     78 
     79   // The current state of the download.
     80   content::DownloadItem::DownloadState state;
     81 
     82   // Whether and how the download is dangerous.
     83   content::DownloadDangerType danger_type;
     84 
     85   // The reason the download was interrupted, if
     86   // state == DownloadItem::INTERRUPTED
     87   content::DownloadInterruptReason interrupt_reason;
     88 
     89   // The id of the download in the database. Is not changed by UpdateDownload().
     90   uint32 id;
     91 
     92   // Whether this download has ever been opened from the browser.
     93   bool opened;
     94 
     95   // The id and name of the extension that created this download.
     96   std::string by_ext_id;
     97   std::string by_ext_name;
     98 };
     99 
    100 }  // namespace history
    101 
    102 #endif  // CHROME_BROWSER_HISTORY_DOWNLOAD_ROW_H_
    103