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 // This file contains download browser tests that are known to be runnable | 5 // This file contains download browser tests that are known to be runnable |
6 // in a pure content context. Over time tests should be migrated here. | 6 // in a pure content context. Over time tests should be migrated here. |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const net::BoundNetLog& bound_net_log, | 166 const net::BoundNetLog& bound_net_log, |
167 base::WeakPtr<DownloadDestinationObserver> observer) override; | 167 base::WeakPtr<DownloadDestinationObserver> observer) override; |
168 | 168 |
169 void AddRenameCallback(base::Closure callback); | 169 void AddRenameCallback(base::Closure callback); |
170 void GetAllRenameCallbacks(std::vector<base::Closure>* results); | 170 void GetAllRenameCallbacks(std::vector<base::Closure>* results); |
171 | 171 |
172 // Do not return until GetAllRenameCallbacks() will return a non-empty list. | 172 // Do not return until GetAllRenameCallbacks() will return a non-empty list. |
173 void WaitForSomeCallback(); | 173 void WaitForSomeCallback(); |
174 | 174 |
175 private: | 175 private: |
176 base::WeakPtrFactory<DownloadFileWithDelayFactory> weak_ptr_factory_; | |
177 std::vector<base::Closure> rename_callbacks_; | 176 std::vector<base::Closure> rename_callbacks_; |
178 bool waiting_; | 177 bool waiting_; |
| 178 base::WeakPtrFactory<DownloadFileWithDelayFactory> weak_ptr_factory_; |
179 | 179 |
180 DISALLOW_COPY_AND_ASSIGN(DownloadFileWithDelayFactory); | 180 DISALLOW_COPY_AND_ASSIGN(DownloadFileWithDelayFactory); |
181 }; | 181 }; |
182 | 182 |
183 DownloadFileWithDelay::DownloadFileWithDelay( | 183 DownloadFileWithDelay::DownloadFileWithDelay( |
184 scoped_ptr<DownloadSaveInfo> save_info, | 184 scoped_ptr<DownloadSaveInfo> save_info, |
185 const base::FilePath& default_download_directory, | 185 const base::FilePath& default_download_directory, |
186 const GURL& url, | 186 const GURL& url, |
187 const GURL& referrer_url, | 187 const GURL& referrer_url, |
188 bool calculate_hash, | 188 bool calculate_hash, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 const RenameCompletionCallback& original_callback, | 221 const RenameCompletionCallback& original_callback, |
222 DownloadInterruptReason reason, | 222 DownloadInterruptReason reason, |
223 const base::FilePath& path) { | 223 const base::FilePath& path) { |
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
225 if (!factory) | 225 if (!factory) |
226 return; | 226 return; |
227 factory->AddRenameCallback(base::Bind(original_callback, reason, path)); | 227 factory->AddRenameCallback(base::Bind(original_callback, reason, path)); |
228 } | 228 } |
229 | 229 |
230 DownloadFileWithDelayFactory::DownloadFileWithDelayFactory() | 230 DownloadFileWithDelayFactory::DownloadFileWithDelayFactory() |
231 : weak_ptr_factory_(this), | 231 : waiting_(false), |
232 waiting_(false) {} | 232 weak_ptr_factory_(this) {} |
| 233 |
233 DownloadFileWithDelayFactory::~DownloadFileWithDelayFactory() {} | 234 DownloadFileWithDelayFactory::~DownloadFileWithDelayFactory() {} |
234 | 235 |
235 DownloadFile* DownloadFileWithDelayFactory::CreateFile( | 236 DownloadFile* DownloadFileWithDelayFactory::CreateFile( |
236 scoped_ptr<DownloadSaveInfo> save_info, | 237 scoped_ptr<DownloadSaveInfo> save_info, |
237 const base::FilePath& default_download_directory, | 238 const base::FilePath& default_download_directory, |
238 const GURL& url, | 239 const GURL& url, |
239 const GURL& referrer_url, | 240 const GURL& referrer_url, |
240 bool calculate_hash, | 241 bool calculate_hash, |
241 scoped_ptr<ByteStreamReader> stream, | 242 scoped_ptr<ByteStreamReader> stream, |
242 const net::BoundNetLog& bound_net_log, | 243 const net::BoundNetLog& bound_net_log, |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 ASSERT_TRUE(test_server.InitializeAndWaitUntilReady()); | 1811 ASSERT_TRUE(test_server.InitializeAndWaitUntilReady()); |
1811 | 1812 |
1812 GURL url = test_server.GetURL("/empty.bin"); | 1813 GURL url = test_server.GetURL("/empty.bin"); |
1813 test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); | 1814 test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); |
1814 | 1815 |
1815 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); | 1816 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); |
1816 // That's it. This should work without crashing. | 1817 // That's it. This should work without crashing. |
1817 } | 1818 } |
1818 | 1819 |
1819 } // namespace content | 1820 } // namespace content |
OLD | NEW |