Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 // // Callback is of type OfflinePageModel::SavePageCallback. | 41 // // Callback is of type OfflinePageModel::SavePageCallback. |
| 42 // model->SavePage(url, std::move(archiver), callback); | 42 // model->SavePage(url, std::move(archiver), callback); |
| 43 // } | 43 // } |
| 44 class OfflinePageMHTMLArchiver : public OfflinePageArchiver { | 44 class OfflinePageMHTMLArchiver : public OfflinePageArchiver { |
| 45 public: | 45 public: |
| 46 // Returns the extension name of the offline page file. | 46 // Returns the extension name of the offline page file. |
| 47 static std::string GetFileNameExtension(); | 47 static std::string GetFileNameExtension(); |
| 48 // Creates a file name for the archive file based on url and title. Public for | 48 // Creates a file name for the archive file based on url and title. Public for |
| 49 // testing. | 49 // testing. |
| 50 static base::FilePath GenerateFileName(const GURL& url, | 50 static base::FilePath GenerateFileName(const GURL& url, |
| 51 const std::string& title); | 51 const std::string& title, |
| 52 int64_t id); | |
|
fgorski
2016/03/30 01:43:30
nit: be consistent with naming, especially if this
jianli
2016/03/31 21:02:42
Done.
| |
| 52 | 53 |
| 53 explicit OfflinePageMHTMLArchiver(content::WebContents* web_contents); | 54 explicit OfflinePageMHTMLArchiver(content::WebContents* web_contents); |
| 54 ~OfflinePageMHTMLArchiver() override; | 55 ~OfflinePageMHTMLArchiver() override; |
| 55 | 56 |
| 56 // OfflinePageArchiver implementation: | 57 // OfflinePageArchiver implementation: |
| 57 void CreateArchive(const base::FilePath& archives_dir, | 58 void CreateArchive(const base::FilePath& archives_dir, |
| 59 int64_t archive_id, | |
| 58 const CreateArchiveCallback& callback) override; | 60 const CreateArchiveCallback& callback) override; |
| 59 | 61 |
| 60 protected: | 62 protected: |
| 61 // Allows to overload the archiver for testing. | 63 // Allows to overload the archiver for testing. |
| 62 OfflinePageMHTMLArchiver(); | 64 OfflinePageMHTMLArchiver(); |
| 63 | 65 |
| 64 // Try to generate MHTML. | 66 // Try to generate MHTML. |
| 65 // Might be overridden for testing purpose. | 67 // Might be overridden for testing purpose. |
| 66 virtual void GenerateMHTML(const base::FilePath& archives_dir); | 68 virtual void GenerateMHTML(const base::FilePath& archives_dir, |
| 69 int64_t archive_id); | |
|
fgorski
2016/03/30 01:43:30
Seems like there is a compilation error here somew
jianli
2016/03/31 21:02:42
Done.
| |
| 67 | 70 |
| 68 // Callback for Generating MHTML. | 71 // Callback for Generating MHTML. |
| 69 void OnGenerateMHTMLDone(const GURL& url, | 72 void OnGenerateMHTMLDone(const GURL& url, |
| 70 const base::FilePath& file_path, | 73 const base::FilePath& file_path, |
| 71 int64_t file_size); | 74 int64_t file_size); |
| 72 | 75 |
| 73 // Sends the result of archiving a page to the client that requested archive | 76 // Sends the result of archiving a page to the client that requested archive |
| 74 // creation. | 77 // creation. |
| 75 void ReportResult(ArchiverResult result, | 78 void ReportResult(ArchiverResult result, |
| 76 const GURL& url, | 79 const GURL& url, |
| 77 const base::FilePath& file_path, | 80 const base::FilePath& file_path, |
| 78 int64_t file_size); | 81 int64_t file_size); |
| 79 void ReportFailure(ArchiverResult result); | 82 void ReportFailure(ArchiverResult result); |
| 80 | 83 |
| 81 private: | 84 private: |
| 82 // Contents of the web page to be serialized. Not owned. | 85 // Contents of the web page to be serialized. Not owned. |
| 83 content::WebContents* web_contents_; | 86 content::WebContents* web_contents_; |
| 84 | 87 |
| 85 CreateArchiveCallback callback_; | 88 CreateArchiveCallback callback_; |
| 86 | 89 |
| 87 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; | 90 base::WeakPtrFactory<OfflinePageMHTMLArchiver> weak_ptr_factory_; |
| 88 | 91 |
| 89 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); | 92 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiver); |
| 90 }; | 93 }; |
| 91 | 94 |
| 92 } // namespace offline_pages | 95 } // namespace offline_pages |
| 93 | 96 |
| 94 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ | 97 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_MHTML_ARCHIVER_H_ |
| OLD | NEW |