diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 16:27:15 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 16:27:15 +0000 |
commit | f15edeb24bd34ef09d6c62b734eca5765f5c2854 (patch) | |
tree | 24d4ef0375b0aab1486fb52d0ae9fa41766b262d /chrome/browser/download/save_file.h | |
parent | a0eca45b109d89137269cb9b5004e8a51309a6b2 (diff) | |
download | chromium_src-f15edeb24bd34ef09d6c62b734eca5765f5c2854.zip chromium_src-f15edeb24bd34ef09d6c62b734eca5765f5c2854.tar.gz chromium_src-f15edeb24bd34ef09d6c62b734eca5765f5c2854.tar.bz2 |
Download code cleanup: share most of the code between DownloadFile and SaveFile.
I'm not really happy about BaseFile, but removing the remaining differences
will require changes to DownloadFileManager and SaveFileManager.
I prefer to do that in small steps.
TEST=unit_tests, browser_tests, ui_tests
BUG=48913
Review URL: http://codereview.chromium.org/3164039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_file.h')
-rw-r--r-- | chrome/browser/download/save_file.h | 47 |
1 files changed, 5 insertions, 42 deletions
diff --git a/chrome/browser/download/save_file.h b/chrome/browser/download/save_file.h index 9960e74..5932c70 100644 --- a/chrome/browser/download/save_file.h +++ b/chrome/browser/download/save_file.h @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_DOWNLOAD_SAVE_FILE_H__ -#define CHROME_BROWSER_DOWNLOAD_SAVE_FILE_H__ +#ifndef CHROME_BROWSER_DOWNLOAD_SAVE_FILE_H_ +#define CHROME_BROWSER_DOWNLOAD_SAVE_FILE_H_ #pragma once #include "base/basictypes.h" #include "base/file_path.h" #include "base/scoped_ptr.h" +#include "chrome/browser/download/base_file.h" #include "chrome/browser/download/save_types.h" // SaveFile ---------------------------------------------------------------- @@ -18,22 +19,11 @@ // the saving job is 'in progress': once the saving job has been completed or // canceled, the SaveFile is destroyed. One SaveFile object represents one item // in a save session. -class SaveFile { +class SaveFile : public BaseFile { public: explicit SaveFile(const SaveFileCreateInfo* info); ~SaveFile(); - // Write a new chunk of data to the file. Returns true on success. - bool AppendDataToFile(const char* data, size_t data_len); - - // Abort the saving job and automatically close the file. - void Cancel(); - - // Rename the saved file. Returns 'true' if the rename was successful. - bool Rename(const FilePath& full_path); - - void Finish(); - // Accessors. int save_id() const { return info_->save_id; } int render_process_id() const { return info_->render_process_id; } @@ -43,37 +33,10 @@ class SaveFile { return info_->save_source; } - int64 bytes_so_far() const { return bytes_so_far_; } - FilePath full_path() const { return full_path_; } - bool path_renamed() const { return path_renamed_; } - bool in_progress() const { return in_progress_; } - private: - // Open or Close the OS file handle. The file 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); - scoped_ptr<const SaveFileCreateInfo> info_; - // OS file handle for writing - FILE* file_; - - // Amount of data received up to this point. We may not know in advance how - // much data to expect since some servers don't provide that information. - int64 bytes_so_far_; - - // Full path to the saved file including the file name. - FilePath full_path_; - - // Whether the saved file is still using its initial temporary path. - bool path_renamed_; - - // Whether the saved file is still receiving data. - bool in_progress_; - DISALLOW_COPY_AND_ASSIGN(SaveFile); }; -#endif // CHROME_BROWSER_DOWNLOAD_SAVE_FILE_H__ +#endif // CHROME_BROWSER_DOWNLOAD_SAVE_FILE_H_ |