summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_file.h
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 00:00:32 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 00:00:32 +0000
commit8af9d0341d6c00ee537adc089f938b120d1d8d34 (patch)
tree334fcf5a09c2b3e12face9d46ae4f25ee62921eb /chrome/browser/download/download_file.h
parent8d292399e6dcdfa776a1de94da07841bf1487f5b (diff)
downloadchromium_src-8af9d0341d6c00ee537adc089f938b120d1d8d34.zip
chromium_src-8af9d0341d6c00ee537adc089f938b120d1d8d34.tar.gz
chromium_src-8af9d0341d6c00ee537adc089f938b120d1d8d34.tar.bz2
Refactor DragDownloadFile so that it can be used by both Windows and MacOSX.
BUG=none TEST=none Review URL: http://codereview.chromium.org/572014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_file.h')
-rw-r--r--chrome/browser/download/download_file.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/chrome/browser/download/download_file.h b/chrome/browser/download/download_file.h
index 352f937..d4df8c4 100644
--- a/chrome/browser/download/download_file.h
+++ b/chrome/browser/download/download_file.h
@@ -49,11 +49,13 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/hash_tables.h"
+#include "base/linked_ptr.h"
#include "base/lock.h"
#include "base/ref_counted.h"
#include "base/timer.h"
#include "chrome/browser/power_save_blocker.h"
#include "googleurl/src/gurl.h"
+#include "net/base/file_stream.h"
namespace net {
class IOBuffer;
@@ -78,6 +80,16 @@ struct DownloadBuffer {
std::vector<Contents> contents;
};
+// DownloadSaveInfo ------------------------------------------------------------
+
+// Holds the information about how to save a download file.
+struct DownloadSaveInfo {
+ FilePath file_path;
+ linked_ptr<net::FileStream> file_stream;
+
+ DownloadSaveInfo() { }
+};
+
// DownloadFile ----------------------------------------------------------------
// These objects live exclusively on the download thread and handle the writing
@@ -111,18 +123,18 @@ class DownloadFile {
int render_view_id() const { return render_view_id_; }
int request_id() const { return request_id_; }
bool path_renamed() const { return path_renamed_; }
- bool in_progress() const { return file_ != NULL; }
+ bool in_progress() const { return file_stream_ != NULL; }
void set_in_progress(bool in_progress) { in_progress_ = in_progress; }
private:
- // Open or Close the OS file handle. The file is opened in the constructor
+ // Open or Close the OS file stream. The stream is opened in the constructor
// based on creation information passed to it, and automatically closed in
// the destructor.
void Close();
- bool Open(const char* open_mode);
+ bool Open();
- // OS file handle for writing
- FILE* file_;
+ // OS file stream for writing
+ linked_ptr<net::FileStream> file_stream_;
// Source URL for the file being downloaded.
GURL source_url_;
@@ -157,6 +169,9 @@ class DownloadFile {
// RAII handle to keep the system from sleeping while we're downloading.
PowerSaveBlocker dont_sleep_;
+ // The provider used to save the download data.
+ DownloadSaveInfo save_info_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadFile);
};
@@ -192,7 +207,7 @@ class DownloadFileManager
void DownloadUrl(const GURL& url,
const GURL& referrer,
const std::string& referrer_charset,
- const FilePath& save_file_path,
+ const DownloadSaveInfo& save_info,
int render_process_host_id,
int render_view_id,
URLRequestContextGetter* request_context_getter);
@@ -201,7 +216,7 @@ class DownloadFileManager
void OnDownloadUrl(const GURL& url,
const GURL& referrer,
const std::string& referrer_charset,
- const FilePath& save_file_path,
+ const DownloadSaveInfo& save_info,
int render_process_host_id,
int render_view_id,
URLRequestContextGetter* request_context_getter);