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

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

Issue 10912173: Replace the DownloadFileManager with direct ownership of DownloadFileImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments and sync'd to r158560 Created 8 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) 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_ITEM_IMPL_DELEGATE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
7 7
8 #include "base/callback.h"
8 #include "base/file_path.h" 9 #include "base/file_path.h"
9 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/public/browser/download_danger_type.h"
12 #include "content/public/browser/download_item.h"
10 13
11 class DownloadFileManager; 14 class DownloadFileManager;
12 class DownloadItemImpl; 15 class DownloadItemImpl;
13 16
14 namespace content { 17 namespace content {
15 class BrowserContext; 18 class BrowserContext;
16 } 19 }
17 20
18 // Delegate for operations that a DownloadItemImpl can't do for itself. 21 // Delegate for operations that a DownloadItemImpl can't do for itself.
19 // The base implementation of this class does nothing (returning false 22 // The base implementation of this class does nothing (returning false
20 // on predicates) so interfaces not of interest to a derived class may 23 // on predicates) so interfaces not of interest to a derived class may
21 // be left unimplemented. 24 // be left unimplemented.
22 class CONTENT_EXPORT DownloadItemImplDelegate { 25 class CONTENT_EXPORT DownloadItemImplDelegate {
23 public: 26 public:
27 typedef base::Callback<void(
28 const FilePath&, // Target path
29 content::DownloadItem::TargetDisposition, // overwrite/uniquify target
30 content::DownloadDangerType,
31 const FilePath& // Intermediate file path
32 )> DownloadTargetCallback;
33
24 DownloadItemImplDelegate(); 34 DownloadItemImplDelegate();
25 virtual ~DownloadItemImplDelegate(); 35 virtual ~DownloadItemImplDelegate();
26 36
27 // Used for catching use-after-free errors. 37 // Used for catching use-after-free errors.
28 void Attach(); 38 void Attach();
29 void Detach(); 39 void Detach();
30 40
31 // Tests if a file type should be opened automatically. 41 // Request determination of the download target from the delegate.
32 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path); 42 virtual void DetermineDownloadTarget(
43 DownloadItemImpl* download, DownloadTargetCallback callback);
33 44
34 // Allows the delegate to override the opening of a download. If it returns 45 // Allows the delegate to override the opening of a download. If it returns
35 // true then it's reponsible for opening the item. 46 // true then it's reponsible for opening the item.
36 virtual bool ShouldOpenDownload(DownloadItemImpl* download); 47 virtual bool ShouldOpenDownload(DownloadItemImpl* download);
37 48
49 // Tests if a file type should be opened automatically.
50 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path);
51
38 // Checks whether a downloaded file still exists and updates the 52 // Checks whether a downloaded file still exists and updates the
39 // file's state if the file is already removed. 53 // file's state if the file is already removed.
40 // The check may or may not result in a later asynchronous call 54 // The check may or may not result in a later asynchronous call
41 // to OnDownloadedFileRemoved(). 55 // to OnDownloadedFileRemoved().
42 virtual void CheckForFileRemoval(DownloadItemImpl* download_item); 56 virtual void CheckForFileRemoval(DownloadItemImpl* download_item);
43 57
44 // If all pre-requisites have been met, complete download processing. 58 // If all pre-requisites have been met, complete download processing.
45 // TODO(rdsmith): Move into DownloadItem. 59 // TODO(rdsmith): Move into DownloadItem.
46 virtual void MaybeCompleteDownload(DownloadItemImpl* download); 60 virtual void MaybeCompleteDownload(DownloadItemImpl* download);
47 61
(...skipping 17 matching lines...) Expand all
65 virtual void AssertStateConsistent(DownloadItemImpl* download) const; 79 virtual void AssertStateConsistent(DownloadItemImpl* download) const;
66 80
67 private: 81 private:
68 // For "Outlives attached DownloadItemImpl" invariant assertion. 82 // For "Outlives attached DownloadItemImpl" invariant assertion.
69 int count_; 83 int count_;
70 84
71 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate); 85 DISALLOW_COPY_AND_ASSIGN(DownloadItemImplDelegate);
72 }; 86 };
73 87
74 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_ 88 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698