OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_ | |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/callback.h" | |
10 #include "content/public/browser/download_item.h" | |
11 | |
12 // A subsystem may use a DownloadCompletionBlocker in conjunction with | |
13 // DownloadManagerDelegate::ShouldCompleteDownload() in order to block the | |
14 // completion of a DownloadItem. | |
Randy Smith (Not in Mondays)
2012/05/16 19:04:53
I'd be explicit about the semantics of this class,
benjhayden
2012/05/16 19:42:30
Done.
| |
15 class DownloadCompletionBlocker : public content::DownloadItem::ExternalData { | |
16 public: | |
17 DownloadCompletionBlocker(); | |
18 virtual ~DownloadCompletionBlocker(); | |
19 | |
20 bool is_complete() const { return is_complete_; } | |
21 | |
22 void set_callback(const base::Closure& callback) { | |
23 if (!is_complete()) | |
24 callback_ = callback; | |
25 } | |
26 | |
27 // Mark this download item as complete with respect to this blocker. Other | |
28 // blockers may continue to block the item. Run |callback_|. | |
29 // Subclasses must chain if they override this method. | |
Randy Smith (Not in Mondays)
2012/05/16 19:04:53
nit, suggestion: My guess as to what you meant by
benjhayden
2012/05/16 19:42:30
Done.
| |
30 virtual void CompleteDownload(); | |
31 | |
32 private: | |
33 bool is_complete_; | |
34 base::Closure callback_; | |
35 | |
36 DISALLOW_COPY_AND_ASSIGN(DownloadCompletionBlocker); | |
37 }; | |
38 | |
39 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_ | |
OLD | NEW |