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

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

Issue 10915180: Make DownloadHistory observe manager, items (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_DOWNLOAD_MANAGER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 int32 download_id, 69 int32 download_id,
70 content::DownloadInterruptReason reason) OVERRIDE; 70 content::DownloadInterruptReason reason) OVERRIDE;
71 virtual int RemoveDownloadsBetween(base::Time remove_begin, 71 virtual int RemoveDownloadsBetween(base::Time remove_begin,
72 base::Time remove_end) OVERRIDE; 72 base::Time remove_end) OVERRIDE;
73 virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE; 73 virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE;
74 virtual int RemoveAllDownloads() OVERRIDE; 74 virtual int RemoveAllDownloads() OVERRIDE;
75 virtual void DownloadUrl( 75 virtual void DownloadUrl(
76 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; 76 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE;
77 virtual void AddObserver(Observer* observer) OVERRIDE; 77 virtual void AddObserver(Observer* observer) OVERRIDE;
78 virtual void RemoveObserver(Observer* observer) OVERRIDE; 78 virtual void RemoveObserver(Observer* observer) OVERRIDE;
79 virtual void OnPersistentStoreQueryComplete( 79 virtual content::DownloadItem* CreateDownloadItem(
80 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE; 80 const FilePath& path,
81 virtual void OnItemAddedToPersistentStore(int32 download_id, 81 const GURL& url,
82 int64 db_handle) OVERRIDE; 82 const GURL& referrer_url,
83 const base::Time& start_time,
84 const base::Time& end_time,
85 int64 received_bytes,
86 int64 total_bytes,
87 content::DownloadItem::DownloadState state,
88 bool opened) OVERRIDE;
83 virtual int InProgressCount() const OVERRIDE; 89 virtual int InProgressCount() const OVERRIDE;
84 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; 90 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
85 virtual void CheckForHistoryFilesRemoval() OVERRIDE; 91 virtual void CheckForHistoryFilesRemoval() OVERRIDE;
86 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; 92 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE;
87 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; 93 virtual content::DownloadItem* GetDownload(int id) OVERRIDE;
88 virtual void SavePageDownloadFinished( 94 virtual void SavePageDownloadFinished(
89 content::DownloadItem* download) OVERRIDE; 95 content::DownloadItem* download) OVERRIDE;
90 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; 96 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE;
91 97
92 private: 98 private:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Does nothing if the download is not in the history DB. 139 // Does nothing if the download is not in the history DB.
134 void RemoveFromActiveList(DownloadItemImpl* download); 140 void RemoveFromActiveList(DownloadItemImpl* download);
135 141
136 // Inform observers that the model has changed. 142 // Inform observers that the model has changed.
137 void NotifyModelChanged(); 143 void NotifyModelChanged();
138 144
139 // Debugging routine to confirm relationship between below 145 // Debugging routine to confirm relationship between below
140 // containers; no-op if NDEBUG. 146 // containers; no-op if NDEBUG.
141 void AssertContainersConsistent() const; 147 void AssertContainersConsistent() const;
142 148
143 // Add a DownloadItem to history_downloads_.
144 void AddDownloadItemToHistory(DownloadItemImpl* item, int64 db_handle);
145
146 // Remove from internal maps. 149 // Remove from internal maps.
147 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); 150 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes);
148 151
149 // Called in response to our request to the DownloadFileManager to 152 // Called in response to our request to the DownloadFileManager to
150 // create a DownloadFile. A |reason| of 153 // create a DownloadFile. A |reason| of
151 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. 154 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success.
152 void OnDownloadFileCreated( 155 void OnDownloadFileCreated(
153 int32 download_id, content::DownloadInterruptReason reason); 156 int32 download_id, content::DownloadInterruptReason reason);
154 157
155 // Called when the delegate has completed determining the download target. 158 // Called when the delegate has completed determining the download target.
156 // Arguments following |download_id| are as per 159 // Arguments following |download_id| are as per
157 // content::DownloadTargetCallback. 160 // content::DownloadTargetCallback.
158 void OnDownloadTargetDetermined( 161 void OnDownloadTargetDetermined(
159 int32 download_id, 162 int32 download_id,
160 const FilePath& target_path, 163 const FilePath& target_path,
161 content::DownloadItem::TargetDisposition disposition, 164 content::DownloadItem::TargetDisposition disposition,
162 content::DownloadDangerType danger_type, 165 content::DownloadDangerType danger_type,
163 const FilePath& intermediate_path); 166 const FilePath& intermediate_path);
164 167
165 // Called when a download entry is committed to the persistent store.
166 void OnDownloadItemAddedToPersistentStore(DownloadItemImpl* item);
167
168 // Called when Save Page As entry is committed to the persistent store.
169 void OnSavePageItemAddedToPersistentStore(DownloadItemImpl* item);
170
171 // Overridden from DownloadItemImplDelegate 168 // Overridden from DownloadItemImplDelegate
172 // (Note that |GetBrowserContext| are present in both interfaces.) 169 // (Note that |GetBrowserContext| are present in both interfaces.)
173 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE; 170 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE;
174 virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE; 171 virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE;
175 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; 172 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE;
176 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; 173 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE;
177 virtual void MaybeCompleteDownload(DownloadItemImpl* download) OVERRIDE; 174 virtual void MaybeCompleteDownload(DownloadItemImpl* download) OVERRIDE;
178 virtual void DownloadStopped(DownloadItemImpl* download) OVERRIDE; 175 virtual void DownloadStopped(DownloadItemImpl* download) OVERRIDE;
179 virtual void DownloadCompleted(DownloadItemImpl* download) OVERRIDE; 176 virtual void DownloadCompleted(DownloadItemImpl* download) OVERRIDE;
180 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE; 177 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE;
181 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE; 178 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE;
182 virtual void DownloadRenamedToIntermediateName( 179 virtual void DownloadRenamedToIntermediateName(
183 DownloadItemImpl* download) OVERRIDE; 180 DownloadItemImpl* download) OVERRIDE;
184 virtual void DownloadRenamedToFinalName(DownloadItemImpl* download) OVERRIDE;
185 virtual void AssertStateConsistent(DownloadItemImpl* download) const OVERRIDE; 181 virtual void AssertStateConsistent(DownloadItemImpl* download) const OVERRIDE;
186 182
187 // Factory for creation of downloads items. 183 // Factory for creation of downloads items.
188 scoped_ptr<content::DownloadItemFactory> factory_; 184 scoped_ptr<content::DownloadItemFactory> factory_;
189 185
190 // |downloads_| is the owning set for all downloads known to the 186 // |downloads_| is the owning set for all downloads known to the
191 // DownloadManager. This includes downloads started by the user in 187 // DownloadManager. This includes downloads started by the user in
192 // this session, downloads initialized from the history system, and 188 // this session, downloads initialized from the history system, and
193 // "save page as" downloads. All other DownloadItem containers in 189 // "save page as" downloads. All other DownloadItem containers in
194 // the DownloadManager are maps; they do not own the DownloadItems. 190 // the DownloadManager are maps; they do not own the DownloadItems.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 224
229 // Allows an embedder to control behavior. Guaranteed to outlive this object. 225 // Allows an embedder to control behavior. Guaranteed to outlive this object.
230 content::DownloadManagerDelegate* delegate_; 226 content::DownloadManagerDelegate* delegate_;
231 227
232 net::NetLog* net_log_; 228 net::NetLog* net_log_;
233 229
234 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); 230 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl);
235 }; 231 };
236 232
237 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 233 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698