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

Unified Diff: chrome/browser/download/download_completion_blocker.h

Issue 10263019: DownloadManagerDelegate::ShouldCompleteDownload(callback) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_completion_blocker.h
diff --git a/chrome/browser/download/download_completion_blocker.h b/chrome/browser/download/download_completion_blocker.h
new file mode 100644
index 0000000000000000000000000000000000000000..796c1431d3305f572d96a2ea82f23f54dfeeebd5
--- /dev/null
+++ b/chrome/browser/download/download_completion_blocker.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_
+#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_
+#pragma once
+
+#include "base/callback.h"
+#include "content/public/browser/download_item.h"
+
+// A subsystem may use a DownloadCompletionBlocker in conjunction with
+// DownloadManagerDelegate::ShouldCompleteDownload() in order to block the
+// completion of a DownloadItem. CompleteDownload() will run the most recent
+// callback set.
+class DownloadCompletionBlocker : public content::DownloadItem::ExternalData {
+ public:
+ DownloadCompletionBlocker();
+ virtual ~DownloadCompletionBlocker();
+
+ bool is_complete() const { return is_complete_; }
+
+ void set_callback(const base::Closure& callback) {
+ if (!is_complete())
+ callback_ = callback;
+ }
+
+ // Mark this download item as complete with respect to this blocker. (Other
+ // blockers may continue to block the item.) Run |callback_|. This method may
+ // only be called once, so |callback_| will only be called once. Subclasses
+ // must call the base implementation if they override this method.
+ virtual void CompleteDownload();
+
+ private:
+ bool is_complete_;
+ base::Closure callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadCompletionBlocker);
+};
+
+#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.cc ('k') | chrome/browser/download/download_completion_blocker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698