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 "content/browser/download/save_package.h" | 5 #include "content/browser/download/save_package.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 download_manager_ = static_cast<DownloadManagerImpl*>( | 284 download_manager_ = static_cast<DownloadManagerImpl*>( |
285 BrowserContext::GetDownloadManager( | 285 BrowserContext::GetDownloadManager( |
286 web_contents()->GetBrowserContext())); | 286 web_contents()->GetBrowserContext())); |
287 DCHECK(download_manager_); | 287 DCHECK(download_manager_); |
288 | 288 |
289 RecordSavePackageEvent(SAVE_PACKAGE_STARTED); | 289 RecordSavePackageEvent(SAVE_PACKAGE_STARTED); |
290 } | 290 } |
291 | 291 |
292 bool SavePackage::Init( | 292 bool SavePackage::Init( |
293 const SavePackageDownloadCreatedCallback& download_created_callback) { | 293 const SavePackageDownloadCreatedCallback& download_created_callback) { |
294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 294 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
295 // Set proper running state. | 295 // Set proper running state. |
296 if (wait_state_ != INITIALIZE) | 296 if (wait_state_ != INITIALIZE) |
297 return false; | 297 return false; |
298 | 298 |
299 wait_state_ = START_PROCESS; | 299 wait_state_ = START_PROCESS; |
300 | 300 |
301 // Initialize the request context and resource dispatcher. | 301 // Initialize the request context and resource dispatcher. |
302 BrowserContext* browser_context = web_contents()->GetBrowserContext(); | 302 BrowserContext* browser_context = web_contents()->GetBrowserContext(); |
303 if (!browser_context) { | 303 if (!browser_context) { |
304 NOTREACHED(); | 304 NOTREACHED(); |
(...skipping 10 matching lines...) Expand all Loading... |
315 "multipart/related" : "text/html"), | 315 "multipart/related" : "text/html"), |
316 request_handle.Pass(), | 316 request_handle.Pass(), |
317 base::Bind(&SavePackage::InitWithDownloadItem, AsWeakPtr(), | 317 base::Bind(&SavePackage::InitWithDownloadItem, AsWeakPtr(), |
318 download_created_callback)); | 318 download_created_callback)); |
319 return true; | 319 return true; |
320 } | 320 } |
321 | 321 |
322 void SavePackage::InitWithDownloadItem( | 322 void SavePackage::InitWithDownloadItem( |
323 const SavePackageDownloadCreatedCallback& download_created_callback, | 323 const SavePackageDownloadCreatedCallback& download_created_callback, |
324 DownloadItemImpl* item) { | 324 DownloadItemImpl* item) { |
325 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 325 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
326 DCHECK(item); | 326 DCHECK(item); |
327 download_ = item; | 327 download_ = item; |
328 download_->AddObserver(this); | 328 download_->AddObserver(this); |
329 // Confirm above didn't delete the tab out from under us. | 329 // Confirm above didn't delete the tab out from under us. |
330 if (!download_created_callback.is_null()) | 330 if (!download_created_callback.is_null()) |
331 download_created_callback.Run(download_); | 331 download_created_callback.Run(download_); |
332 | 332 |
333 // Check save type and process the save page job. | 333 // Check save type and process the save page job. |
334 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { | 334 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { |
335 // Get directory | 335 // Get directory |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 | 1434 |
1435 void SavePackage::FinalizeDownloadEntry() { | 1435 void SavePackage::FinalizeDownloadEntry() { |
1436 DCHECK(download_); | 1436 DCHECK(download_); |
1437 DCHECK(download_manager_); | 1437 DCHECK(download_manager_); |
1438 | 1438 |
1439 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1439 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1440 StopObservation(); | 1440 StopObservation(); |
1441 } | 1441 } |
1442 | 1442 |
1443 } // namespace content | 1443 } // namespace content |
OLD | NEW |