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

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

Issue 11366121: Split DownloadFile::Rename into RenameAndUniquify and RenameAndAnnotate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to LKGR. Created 8 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) 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_FILE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 11 matching lines...) Expand all
22 // the download is 'in progress': once the download has been completed or 22 // the download is 'in progress': once the download has been completed or
23 // cancelled, the DownloadFile is destroyed. 23 // cancelled, the DownloadFile is destroyed.
24 class CONTENT_EXPORT DownloadFile { 24 class CONTENT_EXPORT DownloadFile {
25 public: 25 public:
26 // Callback used with Initialize. On a successful initialize, |reason| will 26 // Callback used with Initialize. On a successful initialize, |reason| will
27 // be DOWNLOAD_INTERRUPT_REASON_NONE; on a failed initialize, it will be 27 // be DOWNLOAD_INTERRUPT_REASON_NONE; on a failed initialize, it will be
28 // set to the reason for the failure. 28 // set to the reason for the failure.
29 typedef base::Callback<void(DownloadInterruptReason reason)> 29 typedef base::Callback<void(DownloadInterruptReason reason)>
30 InitializeCallback; 30 InitializeCallback;
31 31
32 // Callback used with Rename(). On a successful rename |reason| will be 32 // Callback used with Rename*(). On a successful rename |reason| will be
33 // DOWNLOAD_INTERRUPT_REASON_NONE and |path| the path the rename 33 // DOWNLOAD_INTERRUPT_REASON_NONE and |path| the path the rename
34 // was done to. On a failed rename, |reason| will contain the 34 // was done to. On a failed rename, |reason| will contain the
35 // error. 35 // error.
36 typedef base::Callback<void(DownloadInterruptReason reason, 36 typedef base::Callback<void(DownloadInterruptReason reason,
37 const FilePath& path)> RenameCompletionCallback; 37 const FilePath& path)> RenameCompletionCallback;
38 38
39 // Callback used with Detach(). On success, |reason| will be
40 // DOWNLOAD_INTERRUPT_REASON_NONE.
41 typedef base::Callback<void(DownloadInterruptReason reason)>
42 DetachCompletionCallback;
43
44 virtual ~DownloadFile() {} 39 virtual ~DownloadFile() {}
45 40
46 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a network 41 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a network
47 // error code on failure. Upon completion, |callback| will be 42 // error code on failure. Upon completion, |callback| will be
48 // called on the UI thread as per the comment above. 43 // called on the UI thread as per the comment above.
49 virtual void Initialize(const InitializeCallback& callback) = 0; 44 virtual void Initialize(const InitializeCallback& callback) = 0;
50 45
51 // Rename the download file to |full_path|. If that file exists and 46 // Rename the download file to |full_path|. If that file exists
52 // |overwrite_existing_file| is false, |full_path| will be uniquified by 47 // |full_path| will be uniquified by suffixing " (<number>)" to the
53 // suffixing " (<number>)" to the file name before the extension. 48 // file name before the extension.
54 // Upon completion, |callback| will be called on the UI thread 49 virtual void RenameAndUniquify(const FilePath& full_path,
55 // as per the comment above. 50 const RenameCompletionCallback& callback) = 0;
56 virtual void Rename(const FilePath& full_path, 51
57 bool overwrite_existing_file, 52 // Rename the download file to |full_path| and annotate it with
58 const RenameCompletionCallback& callback) = 0; 53 // "Mark of the Web" information about its source. No uniquification
54 // will be performed.
55 virtual void RenameAndAnnotate(const FilePath& full_path,
56 const RenameCompletionCallback& callback) = 0;
59 57
60 // Detach the file so it is not deleted on destruction. 58 // Detach the file so it is not deleted on destruction.
61 // |callback| will be called on the UI thread after detach. 59 virtual void Detach() = 0;
62 virtual void Detach(const DetachCompletionCallback& callback) = 0;
63 60
64 // Abort the download and automatically close the file. 61 // Abort the download and automatically close the file.
65 virtual void Cancel() = 0; 62 virtual void Cancel() = 0;
66 63
67 virtual FilePath FullPath() const = 0; 64 virtual FilePath FullPath() const = 0;
68 virtual bool InProgress() const = 0; 65 virtual bool InProgress() const = 0;
69 virtual int64 BytesSoFar() const = 0; 66 virtual int64 BytesSoFar() const = 0;
70 virtual int64 CurrentSpeed() const = 0; 67 virtual int64 CurrentSpeed() const = 0;
71 68
72 // Set |hash| with sha256 digest for the file. 69 // Set |hash| with sha256 digest for the file.
73 // Returns true if digest is successfully calculated. 70 // Returns true if digest is successfully calculated.
74 virtual bool GetHash(std::string* hash) = 0; 71 virtual bool GetHash(std::string* hash) = 0;
75 72
76 // Returns the current (intermediate) state of the hash as a byte string. 73 // Returns the current (intermediate) state of the hash as a byte string.
77 virtual std::string GetHashState() = 0; 74 virtual std::string GetHashState() = 0;
78 75
79 // For testing. Must be called on FILE thread. 76 // For testing. Must be called on FILE thread.
80 // TODO(rdsmith): Replace use of EnsureNoPendingDownloads() 77 // TODO(rdsmith): Replace use of EnsureNoPendingDownloads()
81 // on the DownloadManager with a test-specific DownloadFileFactory 78 // on the DownloadManager with a test-specific DownloadFileFactory
82 // which keeps track of the number of DownloadFiles. 79 // which keeps track of the number of DownloadFiles.
83 static int GetNumberOfDownloadFiles(); 80 static int GetNumberOfDownloadFiles();
84 81
85 protected: 82 protected:
86 static int number_active_objects_; 83 static int number_active_objects_;
87 }; 84 };
88 85
89 } // namespace content 86 } // namespace content
90 87
91 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 88 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/browser/download/download_file_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698