15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
13eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/download/download_file.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/download/download_request_handle.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/download_save_info.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/net_log.h"
191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "ui/base/page_transition_types.h"
207dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Used for informing the download manager of a new download, since we don't
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// want to pass |DownloadItem|s between threads.
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT DownloadCreateInfo {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DownloadCreateInfo(const base::Time& start_time,
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     int64 total_bytes,
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     const net::BoundNetLog& bound_net_log,
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     bool has_user_gesture,
311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                     ui::PageTransition transition_type,
32f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                     scoped_ptr<DownloadSaveInfo> save_info);
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DownloadCreateInfo();
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ~DownloadCreateInfo();
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string DebugString() const;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The URL from which we are downloading. This is the final URL after any
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // redirection by the server for |url_chain|.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const GURL& url() const;
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The chain of redirects that leading up to and including the final URL.
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<GURL> url_chain;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The URL that referred us.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL referrer_url;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
48effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // The URL of the tab that started us.
49effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GURL tab_url;
50effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
51effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // The referrer URL of the tab that started us.
52effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GURL tab_referrer_url;
53effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The time when the download started.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  base::Time start_time;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The total download size.
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int64 total_bytes;
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
607dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // The ID of the download.
617dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  uint32 download_id;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // True if the download was initiated by user action.
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool has_user_gesture;
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  ui::PageTransition transition_type;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The content-disposition string from the response header.
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string content_disposition;
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The mime type string from the response header (may be overridden).
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string mime_type;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The value of the content type header sent with the downloaded item.  It
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // may be different from |mime_type|, which may be set based on heuristics
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // which may look at the file extension and first few bytes of the file.
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string original_mime_type;
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // For continuing a download, the modification time of the file.
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Storing as a string for exact match to server format on
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // "If-Unmodified-Since" comparison.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string last_modified;
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // For continuing a download, the ETAG of the file.
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string etag;
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The download file save info.
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<DownloadSaveInfo> save_info;
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The remote IP address where the download was fetched from.  Copied from
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // UrlRequest::GetSocketAddress().
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string remote_address;
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The handle to the URLRequest sourcing this download.
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DownloadRequestHandle request_handle;
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The request's |BoundNetLog|, for "source_dependency" linking with the
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // download item's.
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const net::BoundNetLog request_bound_net_log;
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(DownloadCreateInfo);
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_CREATE_INFO_H_
108