Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: content/browser/download/base_file.h

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup, and added fields to DownloadPersistentStoreInfo. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 // File being downloaded and saved to disk. This is a base class 27 // File being downloaded and saved to disk. This is a base class
28 // for DownloadFile and SaveFile, which keep more state information. 28 // for DownloadFile and SaveFile, which keep more state information.
29 class CONTENT_EXPORT BaseFile { 29 class CONTENT_EXPORT BaseFile {
30 public: 30 public:
31 BaseFile(const FilePath& full_path, 31 BaseFile(const FilePath& full_path,
32 const GURL& source_url, 32 const GURL& source_url,
33 const GURL& referrer_url, 33 const GURL& referrer_url,
34 int64 received_bytes, 34 int64 received_bytes,
35 const std::string& initial_hash,
Randy Smith (Not in Mondays) 2011/11/16 18:29:27 In the cases in which we specify an initial_hash,
ahendrickson 2011/11/19 20:18:03 Those are already here. file_stream will be used
Randy Smith (Not in Mondays) 2011/11/21 02:10:16 file_stream is fairly often not set; are you makin
ahendrickson 2011/11/21 20:34:46 My mistake; the file is specified in full_path, no
35 const linked_ptr<net::FileStream>& file_stream); 36 const linked_ptr<net::FileStream>& file_stream);
36 virtual ~BaseFile(); 37 virtual ~BaseFile();
37 38
38 // If calculate_hash is true, sha256 hash will be calculated. 39 // If calculate_hash is true, sha256 hash will be calculated.
39 // Returns net::OK on success, or a network error code on failure. 40 // Returns net::OK on success, or a network error code on failure.
40 net::Error Initialize(bool calculate_hash); 41 net::Error Initialize(bool calculate_hash);
41 42
42 // Write a new chunk of data to the file. 43 // Write a new chunk of data to the file.
43 // Returns net::OK on success (all bytes written to the file), 44 // Returns net::OK on success (all bytes written to the file),
44 // or a network error code on failure. 45 // or a network error code on failure.
(...skipping 12 matching lines...) Expand all
57 // Indicate that the download has finished. No new data will be received. 58 // Indicate that the download has finished. No new data will be received.
58 void Finish(); 59 void Finish();
59 60
60 // Informs the OS that this file came from the internet. 61 // Informs the OS that this file came from the internet.
61 void AnnotateWithSourceInformation(); 62 void AnnotateWithSourceInformation();
62 63
63 FilePath full_path() const { return full_path_; } 64 FilePath full_path() const { return full_path_; }
64 bool in_progress() const { return file_stream_ != NULL; } 65 bool in_progress() const { return file_stream_ != NULL; }
65 int64 bytes_so_far() const { return bytes_so_far_; } 66 int64 bytes_so_far() const { return bytes_so_far_; }
66 67
67 // Set |hash| with sha256 digest for the file. 68 // Gets |hash| with sha256 digest for the file. May be partial.
68 // Returns true if digest is successfully calculated. 69 // Returns true if digest is successfully calculated.
69 virtual bool GetSha256Hash(std::string* hash); 70 virtual bool GetSha256Hash(std::string* hash);
70 71
71 // Returns true if the given hash is considered empty. An empty hash is 72 // Returns true if the given hash is considered empty. An empty hash is
72 // a string of size kSha256HashLen that contains only zeros (initial value 73 // a string of size kSha256HashLen that contains only zeros (initial value
73 // for the hash). 74 // for the hash).
74 static bool IsEmptySha256Hash(const std::string& hash); 75 static bool IsEmptySha256Hash(const std::string& hash);
75 76
76 virtual std::string DebugString() const; 77 virtual std::string DebugString() const;
77 78
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 unsigned char sha256_hash_[kSha256HashLen]; 118 unsigned char sha256_hash_[kSha256HashLen];
118 119
119 // Indicates that this class no longer owns the associated file, and so 120 // Indicates that this class no longer owns the associated file, and so
120 // won't delete it on destruction. 121 // won't delete it on destruction.
121 bool detached_; 122 bool detached_;
122 123
123 DISALLOW_COPY_AND_ASSIGN(BaseFile); 124 DISALLOW_COPY_AND_ASSIGN(BaseFile);
124 }; 125 };
125 126
126 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ 127 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698