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