Commit 513b7e3b authored by rdsmith@chromium.org's avatar rdsmith@chromium.org

Make MaybeCompleteDownload private.

R=asanka@chromium.org


Review URL: https://chromiumcodereview.appspot.com/11412202

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170533 0039d316-1c4b-4281-b951-d872f2087c98
parent 59e44048
...@@ -4,11 +4,10 @@ ...@@ -4,11 +4,10 @@
// File method ordering: Methods in this file are in the same order as // File method ordering: Methods in this file are in the same order as
// in download_item_impl.h, with the following exception: The public // in download_item_impl.h, with the following exception: The public
// interfaces Start, MaybeCompleteDownload, and OnDownloadCompleting // interface Start is placed in chronological order with the other
// are placed in chronological order with the other (private) routines // (private) routines that together define a DownloadItem's state
// that together define a DownloadItem's state transitions // transitions as the download progresses. See "Download progression
// as the download progresses. See "Download progression cascade" later in // cascade" later in this file.
// this file.
// A regular DownloadItem (created for a download in this session of the // A regular DownloadItem (created for a download in this session of the
// browser) normally goes through the following states: // browser) normally goes through the following states:
......
...@@ -154,11 +154,6 @@ class CONTENT_EXPORT DownloadItemImpl ...@@ -154,11 +154,6 @@ class CONTENT_EXPORT DownloadItemImpl
// Start the download // Start the download
virtual void Start(scoped_ptr<DownloadFile> download_file); virtual void Start(scoped_ptr<DownloadFile> download_file);
// If all pre-requisites have been met, complete download processing, i.e. do
// internal cleanup, file rename, and potentially auto-open. (Dangerous
// downloads still may block on user acceptance after this point.)
virtual void MaybeCompleteDownload();
// Needed because of interwining with DownloadManagerImpl -------------------- // Needed because of interwining with DownloadManagerImpl --------------------
// TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl, // TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl,
...@@ -260,10 +255,15 @@ class CONTENT_EXPORT DownloadItemImpl ...@@ -260,10 +255,15 @@ class CONTENT_EXPORT DownloadItemImpl
void OnDownloadRenamedToIntermediateName( void OnDownloadRenamedToIntermediateName(
DownloadInterruptReason reason, const FilePath& full_path); DownloadInterruptReason reason, const FilePath& full_path);
// If all pre-requisites have been met, complete download processing, i.e. do
// internal cleanup, file rename, and potentially auto-open. (Dangerous
// downloads still may block on user acceptance after this point.)
void MaybeCompleteDownload();
// Called when the download is ready to complete. // Called when the download is ready to complete.
// This may perform final rename if necessary and will eventually call // This may perform final rename if necessary and will eventually call
// DownloadItem::Completed(). // DownloadItem::Completed().
virtual void OnDownloadCompleting(); void OnDownloadCompleting();
// Called after the delegate has given the go-ahead to actually complete // Called after the delegate has given the go-ahead to actually complete
// the download. // the download.
...@@ -274,7 +274,7 @@ class CONTENT_EXPORT DownloadItemImpl ...@@ -274,7 +274,7 @@ class CONTENT_EXPORT DownloadItemImpl
// Called if the embedder took over opening a download, to indicate that // Called if the embedder took over opening a download, to indicate that
// the download has been opened. // the download has been opened.
virtual void DelayedDownloadOpened(bool auto_opened); void DelayedDownloadOpened(bool auto_opened);
// Called when the entire download operation (including renaming etc) // Called when the entire download operation (including renaming etc)
// is completed. // is completed.
...@@ -283,7 +283,7 @@ class CONTENT_EXPORT DownloadItemImpl ...@@ -283,7 +283,7 @@ class CONTENT_EXPORT DownloadItemImpl
// Helper routines ----------------------------------------------------------- // Helper routines -----------------------------------------------------------
// Indicate that an error has occurred on the download. // Indicate that an error has occurred on the download.
virtual void Interrupt(DownloadInterruptReason reason); void Interrupt(DownloadInterruptReason reason);
// Cancel the DownloadFile if we have it. // Cancel the DownloadFile if we have it.
void CancelDownloadFile(); void CancelDownloadFile();
......
...@@ -460,13 +460,12 @@ TEST_F(DownloadItemTest, CallbackAfterRename) { ...@@ -460,13 +460,12 @@ TEST_F(DownloadItemTest, CallbackAfterRename) {
::testing::Mock::VerifyAndClearExpectations(download_file); ::testing::Mock::VerifyAndClearExpectations(download_file);
::testing::Mock::VerifyAndClearExpectations(mock_delegate()); ::testing::Mock::VerifyAndClearExpectations(mock_delegate());
item->OnAllDataSaved("");
EXPECT_CALL(*download_file, RenameAndAnnotate(final_path, _)) EXPECT_CALL(*download_file, RenameAndAnnotate(final_path, _))
.WillOnce(ScheduleRenameCallback(final_path)); .WillOnce(ScheduleRenameCallback(final_path));
EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item, _)) EXPECT_CALL(*mock_delegate(), ShouldOpenDownload(item, _))
.WillOnce(Return(true)); .WillOnce(Return(true));
EXPECT_CALL(*download_file, Detach()); EXPECT_CALL(*download_file, Detach());
item->MaybeCompleteDownload(); item->DestinationObserverAsWeakPtr()->DestinationCompleted("");
RunAllPendingInMessageLoops(); RunAllPendingInMessageLoops();
::testing::Mock::VerifyAndClearExpectations(download_file); ::testing::Mock::VerifyAndClearExpectations(download_file);
::testing::Mock::VerifyAndClearExpectations(mock_delegate()); ::testing::Mock::VerifyAndClearExpectations(mock_delegate());
......
...@@ -97,7 +97,6 @@ class MockDownloadItemImpl : public DownloadItemImpl { ...@@ -97,7 +97,6 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_METHOD0(MarkAsComplete, void()); MOCK_METHOD0(MarkAsComplete, void());
MOCK_METHOD1(OnAllDataSaved, void(const std::string&)); MOCK_METHOD1(OnAllDataSaved, void(const std::string&));
MOCK_METHOD0(OnDownloadedFileRemoved, void()); MOCK_METHOD0(OnDownloadedFileRemoved, void());
MOCK_METHOD0(MaybeCompleteDownload, void());
virtual void Start( virtual void Start(
scoped_ptr<DownloadFile> download_file) OVERRIDE { scoped_ptr<DownloadFile> download_file) OVERRIDE {
MockStart(download_file.get()); MockStart(download_file.get());
...@@ -561,10 +560,6 @@ class DownloadManagerTest : public testing::Test { ...@@ -561,10 +560,6 @@ class DownloadManagerTest : public testing::Test {
EXPECT_CALL(item, IsInProgress()) EXPECT_CALL(item, IsInProgress())
.WillOnce(Return(true)); .WillOnce(Return(true));
// History addition should result in a call into MaybeCompleteDownload().
EXPECT_CALL(item, MaybeCompleteDownload())
.WillOnce(Return());
} }
protected: protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment