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