| 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/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "content/public/browser/resource_context.h" | 38 #include "content/public/browser/resource_context.h" |
| 39 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 40 #include "content/public/common/url_constants.h" | 40 #include "content/public/common/url_constants.h" |
| 41 #include "net/base/io_buffer.h" | 41 #include "net/base/io_buffer.h" |
| 42 #include "net/base/mime_util.h" | 42 #include "net/base/mime_util.h" |
| 43 #include "net/base/net_util.h" | 43 #include "net/base/net_util.h" |
| 44 #include "net/url_request/url_request_context.h" | 44 #include "net/url_request/url_request_context.h" |
| 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie
nt.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie
nt.h" |
| 46 | 46 |
| 47 using base::Time; | 47 using base::Time; |
| 48 using content::BrowserContext; |
| 48 using content::BrowserThread; | 49 using content::BrowserThread; |
| 49 using content::DownloadItem; | 50 using content::DownloadItem; |
| 50 using content::NavigationEntry; | 51 using content::NavigationEntry; |
| 51 using content::ResourceDispatcherHostImpl; | 52 using content::ResourceDispatcherHostImpl; |
| 52 using content::WebContents; | 53 using content::WebContents; |
| 53 using WebKit::WebPageSerializerClient; | 54 using WebKit::WebPageSerializerClient; |
| 54 | 55 |
| 55 namespace { | 56 namespace { |
| 56 | 57 |
| 57 // A counter for uniquely identifying each save package. | 58 // A counter for uniquely identifying each save package. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 void SavePackage::InternalInit() { | 257 void SavePackage::InternalInit() { |
| 257 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 258 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 258 if (!rdh) { | 259 if (!rdh) { |
| 259 NOTREACHED(); | 260 NOTREACHED(); |
| 260 return; | 261 return; |
| 261 } | 262 } |
| 262 | 263 |
| 263 file_manager_ = rdh->save_file_manager(); | 264 file_manager_ = rdh->save_file_manager(); |
| 264 DCHECK(file_manager_); | 265 DCHECK(file_manager_); |
| 265 | 266 |
| 266 download_manager_ = web_contents()->GetBrowserContext()->GetDownloadManager(); | 267 download_manager_ = BrowserContext::GetDownloadManager( |
| 268 web_contents()->GetBrowserContext()); |
| 267 DCHECK(download_manager_); | 269 DCHECK(download_manager_); |
| 268 | 270 |
| 269 download_stats::RecordSavePackageEvent(download_stats::SAVE_PACKAGE_STARTED); | 271 download_stats::RecordSavePackageEvent(download_stats::SAVE_PACKAGE_STARTED); |
| 270 } | 272 } |
| 271 | 273 |
| 272 bool SavePackage::Init( | 274 bool SavePackage::Init( |
| 273 const content::SavePackageDownloadCreatedCallback& | 275 const content::SavePackageDownloadCreatedCallback& |
| 274 download_created_callback) { | 276 download_created_callback) { |
| 275 // Set proper running state. | 277 // Set proper running state. |
| 276 if (wait_state_ != INITIALIZE) | 278 if (wait_state_ != INITIALIZE) |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 } | 1360 } |
| 1359 } | 1361 } |
| 1360 | 1362 |
| 1361 void SavePackage::FinalizeDownloadEntry() { | 1363 void SavePackage::FinalizeDownloadEntry() { |
| 1362 DCHECK(download_); | 1364 DCHECK(download_); |
| 1363 DCHECK(download_manager_); | 1365 DCHECK(download_manager_); |
| 1364 | 1366 |
| 1365 download_manager_->SavePageDownloadFinished(download_); | 1367 download_manager_->SavePageDownloadFinished(download_); |
| 1366 StopObservation(); | 1368 StopObservation(); |
| 1367 } | 1369 } |
| OLD | NEW |