| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_BASE_FILE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_BASE_FILE_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_BASE_FILE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_BASE_FILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/linked_ptr.h" | 10 #include "base/linked_ptr.h" |
| 11 #include "chrome/browser/power_save_blocker.h" | 11 #include "chrome/browser/power_save_blocker.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 class FileStream; | 15 class FileStream; |
| 16 } | 16 } |
| 17 | 17 |
| 18 // File being downloaded and saved to disk. This is a base class | 18 // File being downloaded and saved to disk. This is a base class |
| 19 // for DownloadFile and SaveFile, which keep more state information. | 19 // for DownloadFile and SaveFile, which keep more state information. |
| 20 class BaseFile { | 20 class BaseFile { |
| 21 public: | 21 public: |
| 22 BaseFile(const FilePath& full_path, | 22 BaseFile(const FilePath& full_path, |
| 23 const GURL& source_url, | 23 const GURL& source_url, |
| 24 const GURL& referrer_url, | 24 const GURL& referrer_url, |
| 25 int64 received_bytes, |
| 25 const linked_ptr<net::FileStream>& file_stream); | 26 const linked_ptr<net::FileStream>& file_stream); |
| 26 ~BaseFile(); | 27 ~BaseFile(); |
| 27 | 28 |
| 28 bool Initialize(); | 29 bool Initialize(); |
| 29 | 30 |
| 30 // Write a new chunk of data to the file. Returns true on success (all bytes | 31 // Write a new chunk of data to the file. Returns true on success (all bytes |
| 31 // written to the file). | 32 // written to the file). |
| 32 bool AppendDataToFile(const char* data, size_t data_len); | 33 bool AppendDataToFile(const char* data, size_t data_len); |
| 33 | 34 |
| 34 // Rename the download file. Returns true on success. | 35 // Rename the download file. Returns true on success. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // Amount of data received up so far, in bytes. | 74 // Amount of data received up so far, in bytes. |
| 74 int64 bytes_so_far_; | 75 int64 bytes_so_far_; |
| 75 | 76 |
| 76 // RAII handle to keep the system from sleeping while we're downloading. | 77 // RAII handle to keep the system from sleeping while we're downloading. |
| 77 PowerSaveBlocker power_save_blocker_; | 78 PowerSaveBlocker power_save_blocker_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(BaseFile); | 80 DISALLOW_COPY_AND_ASSIGN(BaseFile); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 #endif // CHROME_BROWSER_DOWNLOAD_BASE_FILE_H_ | 83 #endif // CHROME_BROWSER_DOWNLOAD_BASE_FILE_H_ |
| OLD | NEW |