Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 10069014: Save Page As MHTML (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: non-cros works Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/download_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 downloads_.insert(download); 437 downloads_.insert(download);
438 active_downloads_[download_id] = download; 438 active_downloads_[download_id] = download;
439 439
440 return bound_net_log; 440 return bound_net_log;
441 } 441 }
442 442
443 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem( 443 DownloadItem* DownloadManagerImpl::CreateSavePackageDownloadItem(
444 const FilePath& main_file_path, 444 const FilePath& main_file_path,
445 const GURL& page_url, 445 const GURL& page_url,
446 bool is_otr, 446 bool is_otr,
447 const std::string& mime_type,
447 DownloadItem::Observer* observer) { 448 DownloadItem::Observer* observer) {
448 net::BoundNetLog bound_net_log = 449 net::BoundNetLog bound_net_log =
449 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); 450 net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
450 DownloadItem* download = new DownloadItemImpl( 451 DownloadItem* download = new DownloadItemImpl(
451 this, main_file_path, page_url, is_otr, GetNextId(), bound_net_log); 452 this,
453 main_file_path,
454 page_url,
455 is_otr,
456 GetNextId(),
457 mime_type,
458 bound_net_log);
452 459
453 download->AddObserver(observer); 460 download->AddObserver(observer);
454 461
455 DCHECK(!ContainsKey(save_page_downloads_, download->GetId())); 462 DCHECK(!ContainsKey(save_page_downloads_, download->GetId()));
456 downloads_.insert(download); 463 downloads_.insert(download);
457 save_page_downloads_[download->GetId()] = download; 464 save_page_downloads_[download->GetId()] = download;
458 465
459 // Will notify the observer in the callback. 466 // Will notify the observer in the callback.
460 delegate_->AddItemToPersistentStore(download); 467 delegate_->AddItemToPersistentStore(download);
461 468
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (ContainsKey(active_downloads_, download->GetId())) { 593 if (ContainsKey(active_downloads_, download->GetId())) {
587 if (download->IsPersisted()) 594 if (download->IsPersisted())
588 CHECK_EQ(DownloadItem::IN_PROGRESS, download->GetState()); 595 CHECK_EQ(DownloadItem::IN_PROGRESS, download->GetState());
589 if (DownloadItem::IN_PROGRESS != download->GetState()) 596 if (DownloadItem::IN_PROGRESS != download->GetState())
590 CHECK_EQ(DownloadItem::kUninitializedHandle, download->GetDbHandle()); 597 CHECK_EQ(DownloadItem::kUninitializedHandle, download->GetDbHandle());
591 } 598 }
592 if (DownloadItem::IN_PROGRESS == download->GetState()) 599 if (DownloadItem::IN_PROGRESS == download->GetState())
593 CHECK(ContainsKey(active_downloads_, download->GetId())); 600 CHECK(ContainsKey(active_downloads_, download->GetId()));
594 } 601 }
595 602
596 bool DownloadManagerImpl::IsDownloadReadyForCompletion(DownloadItem* download) { 603 bool DownloadManagerImpl::IsDownloadReadyForCompletion(DownloadItem* download) {
asanka 2012/04/26 16:06:20 MaybeCompleteDownload() requires that the download
asanka 2012/04/26 16:06:20 Also add a DCHECK() here to verify that a completi
asanka 2012/04/26 16:11:28 I'm referring to the additional UpdateObsevers() i
benjhayden 2012/04/26 16:33:36 You're suggesting that SavePackage not go through
asanka 2012/04/26 18:15:25 I was actually under the impression that you were
benjhayden 2012/04/26 19:00:48 Ah, nope, sorry. The fact that MaybeCompleteDownlo
asanka 2012/04/26 19:20:26 Thanks! A short note in GDataDownloadObserver::On
benjhayden 2012/04/26 20:09:30 PTAL, Thanks!
604 VLOG(20) << __FUNCTION__ << " all_data_saved=" << download->AllDataSaved()
605 << " safety=" << download->GetSafetyState()
606 << " active=" << (active_downloads_.count(download->GetId()) == 0)
607 << " persisted=" << download->IsPersisted();
597 // If we don't have all the data, the download is not ready for 608 // If we don't have all the data, the download is not ready for
598 // completion. 609 // completion.
599 if (!download->AllDataSaved()) 610 if (!download->AllDataSaved())
600 return false; 611 return false;
601 612
602 // If the download is dangerous, but not yet validated, it's not ready for 613 // If the download is dangerous, but not yet validated, it's not ready for
603 // completion. 614 // completion.
604 if (download->GetSafetyState() == DownloadItem::DANGEROUS) 615 if (download->GetSafetyState() == DownloadItem::DANGEROUS)
605 return false; 616 return false;
606 617
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 if (it->second->IsComplete() && !it->second->GetOpened()) 1219 if (it->second->IsComplete() && !it->second->GetOpened())
1209 ++num_unopened; 1220 ++num_unopened;
1210 } 1221 }
1211 download_stats::RecordOpensOutstanding(num_unopened); 1222 download_stats::RecordOpensOutstanding(num_unopened);
1212 } 1223 }
1213 1224
1214 void DownloadManagerImpl::SetFileManagerForTesting( 1225 void DownloadManagerImpl::SetFileManagerForTesting(
1215 DownloadFileManager* file_manager) { 1226 DownloadFileManager* file_manager) {
1216 file_manager_ = file_manager; 1227 file_manager_ = file_manager;
1217 } 1228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698