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 #ifndef CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 22 matching lines...) Expand all Loading... |
33 static MHTMLGenerationManager* GetInstance(); | 33 static MHTMLGenerationManager* GetInstance(); |
34 | 34 |
35 // GenerateMHTMLCallback is called to report completion and status of MHTML | 35 // GenerateMHTMLCallback is called to report completion and status of MHTML |
36 // generation. On success |file_size| indicates the size of the | 36 // generation. On success |file_size| indicates the size of the |
37 // generated file. On failure |file_size| is -1. | 37 // generated file. On failure |file_size| is -1. |
38 typedef base::Callback<void(int64_t file_size)> GenerateMHTMLCallback; | 38 typedef base::Callback<void(int64_t file_size)> GenerateMHTMLCallback; |
39 | 39 |
40 // Instructs the render view to generate a MHTML representation of the current | 40 // Instructs the render view to generate a MHTML representation of the current |
41 // page for |web_contents|. | 41 // page for |web_contents|. |
42 void SaveMHTML(WebContents* web_contents, | 42 void SaveMHTML(WebContents* web_contents, |
| 43 bool use_binary_encoding, |
43 const base::FilePath& file_path, | 44 const base::FilePath& file_path, |
44 const GenerateMHTMLCallback& callback); | 45 const GenerateMHTMLCallback& callback); |
45 | 46 |
46 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the | 47 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the |
47 // renderer that the MHTML generation finished for a single frame). | 48 // renderer that the MHTML generation finished for a single frame). |
48 void OnSerializeAsMHTMLResponse( | 49 void OnSerializeAsMHTMLResponse( |
49 RenderFrameHostImpl* sender, | 50 RenderFrameHostImpl* sender, |
50 int job_id, | 51 int job_id, |
51 bool mhtml_generation_in_renderer_succeeded, | 52 bool mhtml_generation_in_renderer_succeeded, |
52 const std::set<std::string>& digests_of_uris_of_serialized_resources); | 53 const std::set<std::string>& digests_of_uris_of_serialized_resources); |
(...skipping 13 matching lines...) Expand all Loading... |
66 // been created. | 67 // been created. |
67 void OnFileAvailable(int job_id, base::File browser_file); | 68 void OnFileAvailable(int job_id, base::File browser_file); |
68 | 69 |
69 // Called on the UI thread when a job has been finished. | 70 // Called on the UI thread when a job has been finished. |
70 void JobFinished(Job* job, JobStatus job_status); | 71 void JobFinished(Job* job, JobStatus job_status); |
71 | 72 |
72 // Called on the UI thread after the file got finalized and we have its size. | 73 // Called on the UI thread after the file got finalized and we have its size. |
73 void OnFileClosed(int job_id, JobStatus job_status, int64_t file_size); | 74 void OnFileClosed(int job_id, JobStatus job_status, int64_t file_size); |
74 | 75 |
75 // Creates and registers a new job. | 76 // Creates and registers a new job. |
76 int NewJob(WebContents* web_contents, const GenerateMHTMLCallback& callback); | 77 int NewJob(WebContents* web_contents, |
| 78 bool use_binary_encoding, |
| 79 const GenerateMHTMLCallback& callback); |
77 | 80 |
78 // Finds job by id. Returns nullptr if no job with a given id was found. | 81 // Finds job by id. Returns nullptr if no job with a given id was found. |
79 Job* FindJob(int job_id); | 82 Job* FindJob(int job_id); |
80 | 83 |
81 // Called when the render process connected to a job exits. | 84 // Called when the render process connected to a job exits. |
82 void RenderProcessExited(Job* job); | 85 void RenderProcessExited(Job* job); |
83 | 86 |
84 typedef std::map<int, Job*> IDToJobMap; | 87 typedef std::map<int, Job*> IDToJobMap; |
85 IDToJobMap id_to_job_; | 88 IDToJobMap id_to_job_; |
86 | 89 |
87 int next_job_id_; | 90 int next_job_id_; |
88 | 91 |
89 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); | 92 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); |
90 }; | 93 }; |
91 | 94 |
92 } // namespace content | 95 } // namespace content |
93 | 96 |
94 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ | 97 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ |
OLD | NEW |