| OLD | NEW |
| 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 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 callback_(callback) { | 252 callback_(callback) { |
| 253 download_manager_->AddObserver(this); | 253 download_manager_->AddObserver(this); |
| 254 } | 254 } |
| 255 | 255 |
| 256 virtual ~SavePackageFinishedObserver() { | 256 virtual ~SavePackageFinishedObserver() { |
| 257 if (download_manager_) | 257 if (download_manager_) |
| 258 download_manager_->RemoveObserver(this); | 258 download_manager_->RemoveObserver(this); |
| 259 } | 259 } |
| 260 | 260 |
| 261 // DownloadManager::Observer: | 261 // DownloadManager::Observer: |
| 262 virtual void OnSavePackageSuccessfullyFinished( | 262 virtual void OnSavePackageFinished( |
| 263 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE { | 263 bool success, |
| 264 content::DownloadManager* manager, |
| 265 content::DownloadItem* item) OVERRIDE { |
| 264 callback_.Run(); | 266 callback_.Run(); |
| 265 } | 267 } |
| 266 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE { | 268 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE { |
| 267 download_manager_->RemoveObserver(this); | 269 download_manager_->RemoveObserver(this); |
| 268 download_manager_ = NULL; | 270 download_manager_ = NULL; |
| 269 } | 271 } |
| 270 | 272 |
| 271 private: | 273 private: |
| 272 content::DownloadManager* download_manager_; | 274 content::DownloadManager* download_manager_; |
| 273 base::Closure callback_; | 275 base::Closure callback_; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 GetDownloadManager())->DownloadPath(); | 802 GetDownloadManager())->DownloadPath(); |
| 801 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); | 803 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); |
| 802 ASSERT_TRUE(base::PathExists(filename)); | 804 ASSERT_TRUE(base::PathExists(filename)); |
| 803 std::string contents; | 805 std::string contents; |
| 804 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); | 806 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); |
| 805 EXPECT_EQ("foo", contents); | 807 EXPECT_EQ("foo", contents); |
| 806 } | 808 } |
| 807 | 809 |
| 808 } // namespace | 810 } // namespace |
| 809 | 811 |
| OLD | NEW |