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

Side by Side Diff: chrome/browser/download/download_manager.h

Issue 7995: Move Time, TimeDelta and TimeTicks into namespace base. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // The DownloadManager object manages the process of downloading, including 5 // The DownloadManager object manages the process of downloading, including
6 // updates to the history system and providing the information for displaying 6 // updates to the history system and providing the information for displaying
7 // the downloads view in the Destinations tab. There is one DownloadManager per 7 // the downloads view in the Destinations tab. There is one DownloadManager per
8 // active profile in Chrome. 8 // active profile in Chrome.
9 // 9 //
10 // Each download is represented by a DownloadItem, and all DownloadItems 10 // Each download is represented by a DownloadItem, and all DownloadItems
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 // Constructing from persistent store: 96 // Constructing from persistent store:
97 DownloadItem(const DownloadCreateInfo& info); 97 DownloadItem(const DownloadCreateInfo& info);
98 98
99 // Constructing from user action: 99 // Constructing from user action:
100 DownloadItem(int32 download_id, 100 DownloadItem(int32 download_id,
101 const std::wstring& path, 101 const std::wstring& path,
102 int path_uniquifier, 102 int path_uniquifier,
103 const std::wstring& url, 103 const std::wstring& url,
104 const std::wstring& original_name, 104 const std::wstring& original_name,
105 const Time start_time, 105 const base::Time start_time,
106 int64 download_size, 106 int64 download_size,
107 int render_process_id, 107 int render_process_id,
108 int request_id, 108 int request_id,
109 bool is_dangerous); 109 bool is_dangerous);
110 110
111 ~DownloadItem(); 111 ~DownloadItem();
112 112
113 void Init(bool start_timer); 113 void Init(bool start_timer);
114 114
115 // Public API 115 // Public API
(...skipping 26 matching lines...) Expand all
142 void Remove(bool delete_file); 142 void Remove(bool delete_file);
143 143
144 // Start/stop sending periodic updates to our observers 144 // Start/stop sending periodic updates to our observers
145 void StartProgressTimer(); 145 void StartProgressTimer();
146 void StopProgressTimer(); 146 void StopProgressTimer();
147 147
148 // Simple calculation of the amount of time remaining to completion. Fills 148 // Simple calculation of the amount of time remaining to completion. Fills
149 // |*remaining| with the amount of time remaining if successful. Fails and 149 // |*remaining| with the amount of time remaining if successful. Fails and
150 // returns false if we do not have the number of bytes or the speed so can 150 // returns false if we do not have the number of bytes or the speed so can
151 // not estimate. 151 // not estimate.
152 bool TimeRemaining(TimeDelta* remaining) const; 152 bool TimeRemaining(base::TimeDelta* remaining) const;
153 153
154 // Simple speed estimate in bytes/s 154 // Simple speed estimate in bytes/s
155 int64 CurrentSpeed() const; 155 int64 CurrentSpeed() const;
156 156
157 // Rough percent complete, -1 means we don't know (since we didn't receive a 157 // Rough percent complete, -1 means we don't know (since we didn't receive a
158 // total size). 158 // total size).
159 int PercentComplete() const; 159 int PercentComplete() const;
160 160
161 // Update the download's path, the actual file is renamed on the download 161 // Update the download's path, the actual file is renamed on the download
162 // thread. 162 // thread.
163 void Rename(const std::wstring& full_path); 163 void Rename(const std::wstring& full_path);
164 164
165 // Allow the user to temporarily pause a download or resume a paused download. 165 // Allow the user to temporarily pause a download or resume a paused download.
166 void TogglePause(); 166 void TogglePause();
167 167
168 // Accessors 168 // Accessors
169 DownloadState state() const { return state_; } 169 DownloadState state() const { return state_; }
170 std::wstring file_name() const { return file_name_; } 170 std::wstring file_name() const { return file_name_; }
171 void set_file_name(const std::wstring& name) { file_name_ = name; } 171 void set_file_name(const std::wstring& name) { file_name_ = name; }
172 std::wstring full_path() const { return full_path_; } 172 std::wstring full_path() const { return full_path_; }
173 void set_full_path(const std::wstring& path) { full_path_ = path; } 173 void set_full_path(const std::wstring& path) { full_path_ = path; }
174 int path_uniquifier() const { return path_uniquifier_; } 174 int path_uniquifier() const { return path_uniquifier_; }
175 void set_path_uniquifier(int uniquifier) { path_uniquifier_ = uniquifier; } 175 void set_path_uniquifier(int uniquifier) { path_uniquifier_ = uniquifier; }
176 std::wstring url() const { return url_; } 176 std::wstring url() const { return url_; }
177 int64 total_bytes() const { return total_bytes_; } 177 int64 total_bytes() const { return total_bytes_; }
178 void set_total_bytes(int64 total_bytes) { total_bytes_ = total_bytes; } 178 void set_total_bytes(int64 total_bytes) { total_bytes_ = total_bytes; }
179 int64 received_bytes() const { return received_bytes_; } 179 int64 received_bytes() const { return received_bytes_; }
180 int32 id() const { return id_; } 180 int32 id() const { return id_; }
181 Time start_time() const { return start_time_; } 181 base::Time start_time() const { return start_time_; }
182 void set_db_handle(int64 handle) { db_handle_ = handle; } 182 void set_db_handle(int64 handle) { db_handle_ = handle; }
183 int64 db_handle() const { return db_handle_; } 183 int64 db_handle() const { return db_handle_; }
184 DownloadManager* manager() const { return manager_; } 184 DownloadManager* manager() const { return manager_; }
185 void set_manager(DownloadManager* manager) { manager_ = manager; } 185 void set_manager(DownloadManager* manager) { manager_ = manager; }
186 bool is_paused() const { return is_paused_; } 186 bool is_paused() const { return is_paused_; }
187 void set_is_paused(bool pause) { is_paused_ = pause; } 187 void set_is_paused(bool pause) { is_paused_ = pause; }
188 bool open_when_complete() const { return open_when_complete_; } 188 bool open_when_complete() const { return open_when_complete_; }
189 void set_open_when_complete(bool open) { open_when_complete_ = open; } 189 void set_open_when_complete(bool open) { open_when_complete_ = open; }
190 int render_process_id() const { return render_process_id_; } 190 int render_process_id() const { return render_process_id_; }
191 int request_id() const { return request_id_; } 191 int request_id() const { return request_id_; }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // Start time for calculating remaining time 230 // Start time for calculating remaining time
231 uintptr_t start_tick_; 231 uintptr_t start_tick_;
232 232
233 // The current state of this download 233 // The current state of this download
234 DownloadState state_; 234 DownloadState state_;
235 235
236 // The views of this item in the download shelf and download tab 236 // The views of this item in the download shelf and download tab
237 ObserverList<Observer> observers_; 237 ObserverList<Observer> observers_;
238 238
239 // Time the download was started 239 // Time the download was started
240 Time start_time_; 240 base::Time start_time_;
241 241
242 // Our persistent store handle 242 // Our persistent store handle
243 int64 db_handle_; 243 int64 db_handle_;
244 244
245 // Timer for regularly updating our observers 245 // Timer for regularly updating our observers
246 base::RepeatingTimer<DownloadItem> update_timer_; 246 base::RepeatingTimer<DownloadItem> update_timer_;
247 247
248 // Our owning object 248 // Our owning object
249 DownloadManager* manager_; 249 DownloadManager* manager_;
250 250
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 static void CancelDownloadRequest(int render_process_id, int request_id); 322 static void CancelDownloadRequest(int render_process_id, int request_id);
323 323
324 // Called from a view when a user clicks a UI button or link. 324 // Called from a view when a user clicks a UI button or link.
325 void DownloadCancelled(int32 download_id); 325 void DownloadCancelled(int32 download_id);
326 void PauseDownload(int32 download_id, bool pause); 326 void PauseDownload(int32 download_id, bool pause);
327 void RemoveDownload(int64 download_handle); 327 void RemoveDownload(int64 download_handle);
328 328
329 // Remove downloads after remove_begin (inclusive) and before remove_end 329 // Remove downloads after remove_begin (inclusive) and before remove_end
330 // (exclusive). You may pass in null Time values to do an unbounded delete 330 // (exclusive). You may pass in null Time values to do an unbounded delete
331 // in either direction. 331 // in either direction.
332 int RemoveDownloadsBetween(const Time remove_begin, const Time remove_end); 332 int RemoveDownloadsBetween(const base::Time remove_begin,
333 const base::Time remove_end);
333 334
334 // Remove downloads will delete all downloads that have a timestamp that is 335 // Remove downloads will delete all downloads that have a timestamp that is
335 // the same or more recent than |remove_begin|. The number of downloads 336 // the same or more recent than |remove_begin|. The number of downloads
336 // deleted is returned back to the caller. 337 // deleted is returned back to the caller.
337 int RemoveDownloads(const Time remove_begin); 338 int RemoveDownloads(const base::Time remove_begin);
338 339
339 // Download the object at the URL. Used in cases such as "Save Link As..." 340 // Download the object at the URL. Used in cases such as "Save Link As..."
340 void DownloadUrl(const GURL& url, 341 void DownloadUrl(const GURL& url,
341 const GURL& referrer, 342 const GURL& referrer,
342 WebContents* web_contents); 343 WebContents* web_contents);
343 344
344 // Allow objects to observe the download creation process. 345 // Allow objects to observe the download creation process.
345 void AddObserver(Observer* observer); 346 void AddObserver(Observer* observer);
346 347
347 // Remove a download observer from ourself. 348 // Remove a download observer from ourself.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 412
412 // Called back after a target path for the file to be downloaded to has been 413 // Called back after a target path for the file to be downloaded to has been
413 // determined, either automatically based on the suggested file name, or by 414 // determined, either automatically based on the suggested file name, or by
414 // the user in a Save As dialog box. 415 // the user in a Save As dialog box.
415 void ContinueStartDownload(DownloadCreateInfo* info, 416 void ContinueStartDownload(DownloadCreateInfo* info,
416 const std::wstring& target_path); 417 const std::wstring& target_path);
417 418
418 // Update the history service for a particular download. 419 // Update the history service for a particular download.
419 void UpdateHistoryForDownload(DownloadItem* download); 420 void UpdateHistoryForDownload(DownloadItem* download);
420 void RemoveDownloadFromHistory(DownloadItem* download); 421 void RemoveDownloadFromHistory(DownloadItem* download);
421 void RemoveDownloadsFromHistoryBetween(const Time remove_begin, 422 void RemoveDownloadsFromHistoryBetween(const base::Time remove_begin,
422 const Time remove_before); 423 const base::Time remove_before);
423 424
424 // Inform the notification service of download starts and stops. 425 // Inform the notification service of download starts and stops.
425 void NotifyAboutDownloadStart(); 426 void NotifyAboutDownloadStart();
426 void NotifyAboutDownloadStop(); 427 void NotifyAboutDownloadStop();
427 428
428 // Create an extension based on the file name and mime type. 429 // Create an extension based on the file name and mime type.
429 void GenerateExtension(const std::wstring& file_name, 430 void GenerateExtension(const std::wstring& file_name,
430 const std::string& mime_type, 431 const std::string& mime_type,
431 std::wstring* generated_extension); 432 std::wstring* generated_extension);
432 433
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 551
551 // The "Save As" dialog box used to ask the user where a file should be 552 // The "Save As" dialog box used to ask the user where a file should be
552 // saved. 553 // saved.
553 scoped_refptr<SelectFileDialog> select_file_dialog_; 554 scoped_refptr<SelectFileDialog> select_file_dialog_;
554 555
555 DISALLOW_EVIL_CONSTRUCTORS(DownloadManager); 556 DISALLOW_EVIL_CONSTRUCTORS(DownloadManager);
556 }; 557 };
557 558
558 559
559 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H__ 560 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698