• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "chrome/browser/download/download_completion_blocker.h"
6 
7 #include "base/logging.h"
8 
DownloadCompletionBlocker()9 DownloadCompletionBlocker::DownloadCompletionBlocker()
10   : is_complete_(false) {
11 }
12 
~DownloadCompletionBlocker()13 DownloadCompletionBlocker::~DownloadCompletionBlocker() {
14 }
15 
CompleteDownload()16 void DownloadCompletionBlocker::CompleteDownload() {
17   // Do not run |callback_| more than once.
18   if (is_complete_)
19     return;
20   is_complete_ = true;
21 
22   if (callback_.is_null())
23     return;
24   callback_.Run();
25   // |callback_| may delete |this|, so do not rely on |this| after running
26   // |callback_|!
27 }
28