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 <map> | 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
9 | 11 |
10 #include "base/files/file.h" | 12 #include "base/files/file.h" |
11 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
12 #include "base/process/process.h" | 14 #include "base/process/process.h" |
13 #include "ipc/ipc_platform_file.h" | 15 #include "ipc/ipc_platform_file.h" |
| 16 #include "url/gurl.h" |
14 | 17 |
15 namespace base { | 18 namespace base { |
16 class FilePath; | 19 class FilePath; |
17 } | 20 } |
18 | 21 |
19 namespace content { | 22 namespace content { |
20 | 23 |
21 class WebContents; | 24 class WebContents; |
22 | 25 |
23 // The class and all of its members live on the UI thread. Only static methods | 26 // The class and all of its members live on the UI thread. Only static methods |
24 // are executed on other threads. | 27 // are executed on other threads. |
25 class MHTMLGenerationManager { | 28 class MHTMLGenerationManager { |
26 public: | 29 public: |
27 static MHTMLGenerationManager* GetInstance(); | 30 static MHTMLGenerationManager* GetInstance(); |
28 | 31 |
29 // GenerateMHTMLCallback is called to report completion and status of MHTML | 32 // GenerateMHTMLCallback is called to report completion and status of MHTML |
30 // generation. On success |file_size| indicates the size of the | 33 // generation. On success |file_size| indicates the size of the |
31 // generated file. On failure |file_size| is -1. | 34 // generated file. On failure |file_size| is -1. |
32 typedef base::Callback<void(int64 file_size)> GenerateMHTMLCallback; | 35 typedef base::Callback<void(int64 file_size)> GenerateMHTMLCallback; |
33 | 36 |
34 // Instructs the render view to generate a MHTML representation of the current | 37 // Instructs the render view to generate a MHTML representation of the current |
35 // page for |web_contents|. | 38 // page for |web_contents|. |
36 void SaveMHTML(WebContents* web_contents, | 39 void SaveMHTML(WebContents* web_contents, |
37 const base::FilePath& file_path, | 40 const base::FilePath& file_path, |
38 const GenerateMHTMLCallback& callback); | 41 const GenerateMHTMLCallback& callback); |
39 | 42 |
40 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the | 43 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the |
41 // renderer that the MHTML generation finished for a single frame). | 44 // renderer that the MHTML generation finished for a single frame). |
42 void OnSavedFrameAsMHTML(int job_id, | 45 void OnSerializeAsMHTMLResponse( |
43 bool mhtml_generation_in_renderer_succeeded); | 46 int job_id, |
| 47 bool mhtml_generation_in_renderer_succeeded, |
| 48 const std::set<std::string>& digests_of_uris_of_serialized_resources); |
44 | 49 |
45 private: | 50 private: |
46 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>; | 51 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>; |
47 class Job; | 52 class Job; |
48 enum class JobStatus { SUCCESS, FAILURE }; | 53 enum class JobStatus { SUCCESS, FAILURE }; |
49 | 54 |
50 MHTMLGenerationManager(); | 55 MHTMLGenerationManager(); |
51 virtual ~MHTMLGenerationManager(); | 56 virtual ~MHTMLGenerationManager(); |
52 | 57 |
53 // Called on the file thread to create |file|. | 58 // Called on the file thread to create |file|. |
(...skipping 22 matching lines...) Expand all Loading... |
76 IDToJobMap id_to_job_; | 81 IDToJobMap id_to_job_; |
77 | 82 |
78 int next_job_id_; | 83 int next_job_id_; |
79 | 84 |
80 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); | 85 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); |
81 }; | 86 }; |
82 | 87 |
83 } // namespace content | 88 } // namespace content |
84 | 89 |
85 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ | 90 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ |
OLD | NEW |