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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 waiting_ = true; | 82 waiting_ = true; |
83 content::RunMessageLoop(); | 83 content::RunMessageLoop(); |
84 waiting_ = false; | 84 waiting_ = false; |
85 return persisted_; | 85 return persisted_; |
86 } | 86 } |
87 | 87 |
88 virtual void OnDownloadStored(DownloadItem* item, | 88 virtual void OnDownloadStored(DownloadItem* item, |
89 const history::DownloadRow& info) OVERRIDE { | 89 const history::DownloadRow& info) OVERRIDE { |
90 persisted_ = filter_.Run(item, info); | 90 persisted_ = filter_.Run(item, info); |
91 if (persisted_ && waiting_) | 91 if (persisted_ && waiting_) |
92 MessageLoopForUI::current()->Quit(); | 92 base::MessageLoopForUI::current()->Quit(); |
93 } | 93 } |
94 | 94 |
95 private: | 95 private: |
96 Profile* profile_; | 96 Profile* profile_; |
97 DownloadItem* item_; | 97 DownloadItem* item_; |
98 PersistedFilter filter_; | 98 PersistedFilter filter_; |
99 bool waiting_; | 99 bool waiting_; |
100 bool persisted_; | 100 bool persisted_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(DownloadPersistedObserver); | 102 DISALLOW_COPY_AND_ASSIGN(DownloadPersistedObserver); |
(...skipping 19 matching lines...) Expand all Loading... |
122 return removed_; | 122 return removed_; |
123 } | 123 } |
124 | 124 |
125 virtual void OnDownloadStored(DownloadItem* item, | 125 virtual void OnDownloadStored(DownloadItem* item, |
126 const history::DownloadRow& info) OVERRIDE { | 126 const history::DownloadRow& info) OVERRIDE { |
127 } | 127 } |
128 | 128 |
129 virtual void OnDownloadsRemoved(const DownloadHistory::IdSet& ids) OVERRIDE { | 129 virtual void OnDownloadsRemoved(const DownloadHistory::IdSet& ids) OVERRIDE { |
130 removed_ = ids.find(download_id_) != ids.end(); | 130 removed_ = ids.find(download_id_) != ids.end(); |
131 if (removed_ && waiting_) | 131 if (removed_ && waiting_) |
132 MessageLoopForUI::current()->Quit(); | 132 base::MessageLoopForUI::current()->Quit(); |
133 } | 133 } |
134 | 134 |
135 private: | 135 private: |
136 bool removed_; | 136 bool removed_; |
137 bool waiting_; | 137 bool waiting_; |
138 int32 download_id_; | 138 int32 download_id_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(DownloadRemovedObserver); | 140 DISALLOW_COPY_AND_ASSIGN(DownloadRemovedObserver); |
141 }; | 141 }; |
142 | 142 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 | 224 |
225 private: | 225 private: |
226 // DownloadManager::Observer | 226 // DownloadManager::Observer |
227 virtual void OnDownloadCreated( | 227 virtual void OnDownloadCreated( |
228 DownloadManager* manager, DownloadItem* item) OVERRIDE { | 228 DownloadManager* manager, DownloadItem* item) OVERRIDE { |
229 DCHECK_EQ(manager, manager_); | 229 DCHECK_EQ(manager, manager_); |
230 items_seen_.push_back(item); | 230 items_seen_.push_back(item); |
231 | 231 |
232 if (waiting_) | 232 if (waiting_) |
233 MessageLoopForUI::current()->Quit(); | 233 base::MessageLoopForUI::current()->Quit(); |
234 } | 234 } |
235 | 235 |
236 virtual void ManagerGoingDown(DownloadManager* manager) OVERRIDE { | 236 virtual void ManagerGoingDown(DownloadManager* manager) OVERRIDE { |
237 manager_->RemoveObserver(this); | 237 manager_->RemoveObserver(this); |
238 manager_ = NULL; | 238 manager_ = NULL; |
239 if (waiting_) | 239 if (waiting_) |
240 MessageLoopForUI::current()->Quit(); | 240 base::MessageLoopForUI::current()->Quit(); |
241 } | 241 } |
242 | 242 |
243 bool waiting_; | 243 bool waiting_; |
244 DownloadManager* manager_; | 244 DownloadManager* manager_; |
245 std::vector<DownloadItem*> items_seen_; | 245 std::vector<DownloadItem*> items_seen_; |
246 | 246 |
247 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver); | 247 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver); |
248 }; | 248 }; |
249 | 249 |
250 class SavePackageFinishedObserver : public content::DownloadManager::Observer { | 250 class SavePackageFinishedObserver : public content::DownloadManager::Observer { |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 GetDownloadManager())->DownloadPath(); | 797 GetDownloadManager())->DownloadPath(); |
798 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); | 798 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); |
799 EXPECT_TRUE(file_util::PathExists(filename)); | 799 EXPECT_TRUE(file_util::PathExists(filename)); |
800 std::string contents; | 800 std::string contents; |
801 EXPECT_TRUE(file_util::ReadFileToString(filename, &contents)); | 801 EXPECT_TRUE(file_util::ReadFileToString(filename, &contents)); |
802 EXPECT_EQ("foo", contents); | 802 EXPECT_EQ("foo", contents); |
803 } | 803 } |
804 | 804 |
805 } // namespace | 805 } // namespace |
806 | 806 |
OLD | NEW |