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

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

Issue 8401001: Fix history importing by delaying DownloadManager creation. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: " 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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
11 // DownloadItem::Observer: 11 // DownloadItem::Observer:
12 // - allows observers to receive notifications about one download from start 12 // - allows observers to receive notifications about one download from start
13 // to completion 13 // to completion
14 // Use AddObserver() / RemoveObserver() on the appropriate download object to 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to
15 // receive state updates. 15 // receive state updates.
16 16
17 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 17 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
18 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 18 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
19 #pragma once 19 #pragma once
20 20
21 #include <string> 21 #include <string>
22 22
23 #include "base/basictypes.h" 23 #include "base/basictypes.h"
24 #include "base/file_path.h" 24 #include "base/file_path.h"
25 #include "base/observer_list.h" 25 #include "base/observer_list.h"
26 #include "base/time.h" 26 #include "base/time.h"
27 #include "base/timer.h" 27 #include "base/timer.h"
28 #include "content/browser/download/download_request_handle.h" 28 #include "content/browser/download/download_request_handle.h"
29 #include "content/browser/download/download_id.h"
Miranda Callahan 2011/10/27 17:00:19 nit: alphabetization
benjhayden 2011/10/27 19:04:41 Done.
29 #include "content/browser/download/download_state_info.h" 30 #include "content/browser/download/download_state_info.h"
30 #include "content/browser/download/interrupt_reasons.h" 31 #include "content/browser/download/interrupt_reasons.h"
31 #include "content/common/content_export.h" 32 #include "content/common/content_export.h"
32 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
33 #include "net/base/net_errors.h" 34 #include "net/base/net_errors.h"
34 35
35 class DownloadFileManager; 36 class DownloadFileManager;
36 class DownloadId; 37 class DownloadId;
37 class DownloadManager; 38 class DownloadManager;
38 struct DownloadCreateInfo; 39 struct DownloadCreateInfo;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 // Called when a downloaded file has been opened. 109 // Called when a downloaded file has been opened.
109 virtual void OnDownloadOpened(DownloadItem* download) = 0; 110 virtual void OnDownloadOpened(DownloadItem* download) = 0;
110 111
111 protected: 112 protected:
112 virtual ~Observer() {} 113 virtual ~Observer() {}
113 }; 114 };
114 115
115 // Constructing from persistent store: 116 // Constructing from persistent store:
116 DownloadItem(DownloadManager* download_manager, 117 DownloadItem(DownloadManager* download_manager,
117 const DownloadPersistentStoreInfo& info); 118 const DownloadPersistentStoreInfo& info,
119 const DownloadId& download_id);
Randy Smith (Not in Mondays) 2011/10/27 18:01:44 Long term, when we construct from the persistent s
benjhayden 2011/10/27 19:04:41 Done.
118 120
119 // Constructing for a regular download: 121 // Constructing for a regular download:
120 DownloadItem(DownloadManager* download_manager, 122 DownloadItem(DownloadManager* download_manager,
121 const DownloadCreateInfo& info, 123 const DownloadCreateInfo& info,
122 const DownloadRequestHandle& request_handle, 124 const DownloadRequestHandle& request_handle,
123 bool is_otr); 125 bool is_otr);
124 126
125 // Constructing for the "Save Page As..." feature: 127 // Constructing for the "Save Page As..." feature:
126 DownloadItem(DownloadManager* download_manager, 128 DownloadItem(DownloadManager* download_manager,
127 const FilePath& path, 129 const FilePath& path,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 std::string suggested_filename() const { return suggested_filename_; } 272 std::string suggested_filename() const { return suggested_filename_; }
271 std::string content_disposition() const { return content_disposition_; } 273 std::string content_disposition() const { return content_disposition_; }
272 std::string mime_type() const { return mime_type_; } 274 std::string mime_type() const { return mime_type_; }
273 std::string original_mime_type() const { return original_mime_type_; } 275 std::string original_mime_type() const { return original_mime_type_; }
274 std::string referrer_charset() const { return referrer_charset_; } 276 std::string referrer_charset() const { return referrer_charset_; }
275 int64 total_bytes() const { return total_bytes_; } 277 int64 total_bytes() const { return total_bytes_; }
276 void set_total_bytes(int64 total_bytes) { 278 void set_total_bytes(int64 total_bytes) {
277 total_bytes_ = total_bytes; 279 total_bytes_ = total_bytes;
278 } 280 }
279 int64 received_bytes() const { return received_bytes_; } 281 int64 received_bytes() const { return received_bytes_; }
280 int32 id() const { return download_id_; } 282 int32 id() const { return download_id_.local(); }
281 DownloadId global_id() const; 283 const DownloadId& global_id() const { return download_id_; }
Randy Smith (Not in Mondays) 2011/10/27 18:01:44 Hmmm. I'm actually a litte uncomfortable about th
benjhayden 2011/10/27 19:04:41 Done.
282 base::Time start_time() const { return start_time_; } 284 base::Time start_time() const { return start_time_; }
283 base::Time end_time() const { return end_time_; } 285 base::Time end_time() const { return end_time_; }
284 void set_db_handle(int64 handle) { db_handle_ = handle; } 286 void set_db_handle(int64 handle) { db_handle_ = handle; }
285 int64 db_handle() const { return db_handle_; } 287 int64 db_handle() const { return db_handle_; }
286 DownloadManager* download_manager() { return download_manager_; } 288 DownloadManager* download_manager() { return download_manager_; }
287 bool is_paused() const { return is_paused_; } 289 bool is_paused() const { return is_paused_; }
288 bool open_when_complete() const { return open_when_complete_; } 290 bool open_when_complete() const { return open_when_complete_; }
289 void set_open_when_complete(bool open) { open_when_complete_ = open; } 291 void set_open_when_complete(bool open) { open_when_complete_ = open; }
290 bool file_externally_removed() const { return file_externally_removed_; } 292 bool file_externally_removed() const { return file_externally_removed_; }
291 SafetyState safety_state() const { return safety_state_; } 293 SafetyState safety_state() const { return safety_state_; }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void UpdateTarget(); 374 void UpdateTarget();
373 375
374 // State information used by the download manager. 376 // State information used by the download manager.
375 DownloadStateInfo state_info_; 377 DownloadStateInfo state_info_;
376 378
377 // The handle to the request information. Used for operations outside the 379 // The handle to the request information. Used for operations outside the
378 // download system. 380 // download system.
379 DownloadRequestHandle request_handle_; 381 DownloadRequestHandle request_handle_;
380 382
381 // Download ID assigned by DownloadResourceHandler. 383 // Download ID assigned by DownloadResourceHandler.
382 int32 download_id_; 384 DownloadId download_id_;
383 385
384 // Full path to the downloaded or downloading file. 386 // Full path to the downloaded or downloading file.
385 FilePath full_path_; 387 FilePath full_path_;
386 388
387 // A number that should be appended to the path to make it unique, or 0 if the 389 // A number that should be appended to the path to make it unique, or 0 if the
388 // path should be used as is. 390 // path should be used as is.
389 int path_uniquifier_; 391 int path_uniquifier_;
390 392
391 // The chain of redirects that leading up to and including the final URL. 393 // The chain of redirects that leading up to and including the final URL.
392 std::vector<GURL> url_chain_; 394 std::vector<GURL> url_chain_;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // only. 486 // only.
485 bool open_enabled_; 487 bool open_enabled_;
486 488
487 // Did the delegate delay calling Complete on this download? 489 // Did the delegate delay calling Complete on this download?
488 bool delegate_delayed_complete_; 490 bool delegate_delayed_complete_;
489 491
490 DISALLOW_COPY_AND_ASSIGN(DownloadItem); 492 DISALLOW_COPY_AND_ASSIGN(DownloadItem);
491 }; 493 };
492 494
493 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 495 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698