Chromium Code Reviews| 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 #ifndef CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ | 4 #ifndef CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ |
| 5 #define CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ | 5 #define CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 void OnSerializeAsMHTMLResponse( | 54 void OnSerializeAsMHTMLResponse( |
| 55 RenderFrameHostImpl* sender, | 55 RenderFrameHostImpl* sender, |
| 56 int job_id, | 56 int job_id, |
| 57 MhtmlSaveStatus save_status, | 57 MhtmlSaveStatus save_status, |
| 58 const std::set<std::string>& digests_of_uris_of_serialized_resources, | 58 const std::set<std::string>& digests_of_uris_of_serialized_resources, |
| 59 base::TimeDelta renderer_main_thread_time); | 59 base::TimeDelta renderer_main_thread_time); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>; | 62 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>; |
| 63 class Job; | 63 class Job; |
| 64 struct FileCreationResult { | |
| 65 base::File file; | |
| 66 int header_size = 0; | |
| 67 }; | |
| 64 | 68 |
| 65 MHTMLGenerationManager(); | 69 MHTMLGenerationManager(); |
| 66 virtual ~MHTMLGenerationManager(); | 70 virtual ~MHTMLGenerationManager(); |
| 67 | 71 |
| 68 // Called on the file thread to create |file|. | 72 // Called on the file thread to create |file|. |
|
carlosk
2017/04/25 01:28:08
Append "and write the MHTML header into it".
| |
| 69 static base::File CreateFile(const base::FilePath& file_path); | 73 static FileCreationResult CreateFileAndWriteHeader( |
| 74 const base::FilePath& file_path, | |
| 75 const std::string& header); | |
| 70 | 76 |
| 71 // Called on the UI thread when the file that should hold the MHTML data has | 77 // Called on the UI thread when the file that should hold the MHTML data has |
| 72 // been created. | 78 // been created. |
| 73 void OnFileAvailable(int job_id, base::File browser_file); | 79 void OnFileAvailable(int job_id, FileCreationResult result); |
| 74 | 80 |
| 75 // Called on the UI thread when a job has been finished. | 81 // Called on the UI thread when a job has been finished. |
| 76 void JobFinished(Job* job, MhtmlSaveStatus save_status); | 82 void JobFinished(Job* job, MhtmlSaveStatus save_status); |
| 77 | 83 |
| 78 // Called on the UI thread after the file got finalized and we have its size. | 84 // Called on the UI thread after the file got finalized and we have its size. |
| 79 void OnFileClosed( | 85 void OnFileClosed( |
| 80 int job_id, | 86 int job_id, |
| 81 const std::tuple<MhtmlSaveStatus, int64_t>& save_status_size); | 87 const std::tuple<MhtmlSaveStatus, int64_t>& save_status_size); |
| 82 | 88 |
| 83 // Creates and registers a new job. | 89 // Creates and registers a new job. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 94 std::map<int, std::unique_ptr<Job>> id_to_job_; | 100 std::map<int, std::unique_ptr<Job>> id_to_job_; |
| 95 | 101 |
| 96 int next_job_id_; | 102 int next_job_id_; |
| 97 | 103 |
| 98 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); | 104 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); |
| 99 }; | 105 }; |
| 100 | 106 |
| 101 } // namespace content | 107 } // namespace content |
| 102 | 108 |
| 103 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ | 109 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ |
| OLD | NEW |