OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 archives_dir.Append(GenerateFileName(url, base::UTF16ToUTF8(title)))); | 107 archives_dir.Append(GenerateFileName(url, base::UTF16ToUTF8(title)))); |
108 | 108 |
109 web_contents_->GenerateMHTML( | 109 web_contents_->GenerateMHTML( |
110 file_path, base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, | 110 file_path, base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, |
111 weak_ptr_factory_.GetWeakPtr(), url, file_path)); | 111 weak_ptr_factory_.GetWeakPtr(), url, file_path)); |
112 } | 112 } |
113 | 113 |
114 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( | 114 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( |
115 const GURL& url, | 115 const GURL& url, |
116 const base::FilePath& file_path, | 116 const base::FilePath& file_path, |
117 int64 file_size) { | 117 int64_t file_size) { |
118 if (file_size < 0) { | 118 if (file_size < 0) { |
119 ReportFailure(ArchiverResult::ERROR_ARCHIVE_CREATION_FAILED); | 119 ReportFailure(ArchiverResult::ERROR_ARCHIVE_CREATION_FAILED); |
120 } else { | 120 } else { |
121 callback_.Run(this, ArchiverResult::SUCCESSFULLY_CREATED, url, file_path, | 121 callback_.Run(this, ArchiverResult::SUCCESSFULLY_CREATED, url, file_path, |
122 file_size); | 122 file_size); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { | 126 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { |
127 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); | 127 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); |
128 callback_.Run(this, result, GURL(), base::FilePath(), 0); | 128 callback_.Run(this, result, GURL(), base::FilePath(), 0); |
129 } | 129 } |
130 | 130 |
131 } // namespace offline_pages | 131 } // namespace offline_pages |
OLD | NEW |