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

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

Issue 10905284: Use the user's preferred downloads directory for creating the initial download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 11 matching lines...) Expand all
22 class SecureHash; 22 class SecureHash;
23 } 23 }
24 namespace net { 24 namespace net {
25 class FileStream; 25 class FileStream;
26 } 26 }
27 27
28 // File being downloaded and saved to disk. This is a base class 28 // File being downloaded and saved to disk. This is a base class
29 // for DownloadFile and SaveFile, which keep more state information. 29 // for DownloadFile and SaveFile, which keep more state information.
30 class CONTENT_EXPORT BaseFile { 30 class CONTENT_EXPORT BaseFile {
31 public: 31 public:
32 BaseFile(const FilePath& full_path, 32 // Either |download_directory| or |full_path| should be non-empty. If
33 // |full_path| isn't specified, a temporary file will be created under
34 // |download_directory|.
35 BaseFile(const FilePath& download_directory,
36 const FilePath& full_path,
33 const GURL& source_url, 37 const GURL& source_url,
34 const GURL& referrer_url, 38 const GURL& referrer_url,
35 int64 received_bytes, 39 int64 received_bytes,
36 bool calculate_hash, 40 bool calculate_hash,
37 const std::string& hash_state, 41 const std::string& hash_state,
38 const linked_ptr<net::FileStream>& file_stream, 42 const linked_ptr<net::FileStream>& file_stream,
39 const net::BoundNetLog& bound_net_log); 43 const net::BoundNetLog& bound_net_log);
40 virtual ~BaseFile(); 44 virtual ~BaseFile();
41 45
42 // Returns net::OK on success, or a network error code on failure. 46 // Returns net::OK on success, or a network error code on failure.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 int64 CurrentSpeedAtTime(base::TimeTicks current_time) const; 105 int64 CurrentSpeedAtTime(base::TimeTicks current_time) const;
102 106
103 // Resets the current state of the hash to the contents of |hash_state_bytes|. 107 // Resets the current state of the hash to the contents of |hash_state_bytes|.
104 virtual bool SetHashState(const std::string& hash_state_bytes); 108 virtual bool SetHashState(const std::string& hash_state_bytes);
105 109
106 net::Error ClearStream(net::Error error); 110 net::Error ClearStream(net::Error error);
107 111
108 static const size_t kSha256HashLen = 32; 112 static const size_t kSha256HashLen = 32;
109 static const unsigned char kEmptySha256Hash[kSha256HashLen]; 113 static const unsigned char kEmptySha256Hash[kSha256HashLen];
110 114
115 // Default download directory to use for temporary file
116 FilePath download_directory_;
Randy Smith (Not in Mondays) 2012/09/14 16:38:16 I'm tempted to suggest that instead of doing this
asanka 2012/09/14 19:11:45 I added a parameter to Initialize() instead and ca
117
111 // Source URL for the file being downloaded. 118 // Source URL for the file being downloaded.
112 GURL source_url_; 119 GURL source_url_;
113 120
114 // The URL where the download was initiated. 121 // The URL where the download was initiated.
115 GURL referrer_url_; 122 GURL referrer_url_;
116 123
117 // OS file stream for writing 124 // OS file stream for writing
118 linked_ptr<net::FileStream> file_stream_; 125 linked_ptr<net::FileStream> file_stream_;
119 126
120 // Amount of data received up so far, in bytes. 127 // Amount of data received up so far, in bytes.
(...skipping 14 matching lines...) Expand all
135 // Indicates that this class no longer owns the associated file, and so 142 // Indicates that this class no longer owns the associated file, and so
136 // won't delete it on destruction. 143 // won't delete it on destruction.
137 bool detached_; 144 bool detached_;
138 145
139 net::BoundNetLog bound_net_log_; 146 net::BoundNetLog bound_net_log_;
140 147
141 DISALLOW_COPY_AND_ASSIGN(BaseFile); 148 DISALLOW_COPY_AND_ASSIGN(BaseFile);
142 }; 149 };
143 150
144 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ 151 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698