Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: content/browser/download/mhtml_generation_manager.h

Issue 2519273002: Fail when saving page as MHTML provides information about the cause. (Closed)
Patch Set: Minor changes. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/files/file.h" 14 #include "base/files/file.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/process/process.h" 17 #include "base/process/process.h"
18 #include "content/common/download/mhtml_save_status.h"
18 #include "content/public/common/mhtml_generation_params.h" 19 #include "content/public/common/mhtml_generation_params.h"
19 #include "ipc/ipc_platform_file.h" 20 #include "ipc/ipc_platform_file.h"
20 21
21 namespace base { 22 namespace base {
22 class FilePath; 23 class FilePath;
23 } 24 }
24 25
25 namespace content { 26 namespace content {
26 27
27 class RenderFrameHostImpl; 28 class RenderFrameHostImpl;
(...skipping 18 matching lines...) Expand all
46 // representation of the current page. 47 // representation of the current page.
47 void SaveMHTML(WebContents* web_contents, 48 void SaveMHTML(WebContents* web_contents,
48 const MHTMLGenerationParams& params, 49 const MHTMLGenerationParams& params,
49 const GenerateMHTMLCallback& callback); 50 const GenerateMHTMLCallback& callback);
50 51
51 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the 52 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the
52 // renderer that the MHTML generation finished for a single frame). 53 // renderer that the MHTML generation finished for a single frame).
53 void OnSerializeAsMHTMLResponse( 54 void OnSerializeAsMHTMLResponse(
54 RenderFrameHostImpl* sender, 55 RenderFrameHostImpl* sender,
55 int job_id, 56 int job_id,
56 bool mhtml_generation_in_renderer_succeeded, 57 MhtmlSaveStatus save_status,
57 const std::set<std::string>& digests_of_uris_of_serialized_resources, 58 const std::set<std::string>& digests_of_uris_of_serialized_resources,
58 base::TimeDelta renderer_main_thread_time); 59 base::TimeDelta renderer_main_thread_time);
59 60
60 private: 61 private:
61 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>; 62 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>;
62 class Job; 63 class Job;
63 enum class JobStatus { SUCCESS, FAILURE };
64 64
65 MHTMLGenerationManager(); 65 MHTMLGenerationManager();
66 virtual ~MHTMLGenerationManager(); 66 virtual ~MHTMLGenerationManager();
67 67
68 // Called on the file thread to create |file|. 68 // Called on the file thread to create |file|.
69 static base::File CreateFile(const base::FilePath& file_path); 69 static base::File CreateFile(const base::FilePath& file_path);
70 70
71 // Called on the UI thread when the file that should hold the MHTML data has 71 // Called on the UI thread when the file that should hold the MHTML data has
72 // been created. 72 // been created.
73 void OnFileAvailable(int job_id, base::File browser_file); 73 void OnFileAvailable(int job_id, base::File browser_file);
74 74
75 // Called on the UI thread when a job has been finished. 75 // Called on the UI thread when a job has been finished.
76 void JobFinished(Job* job, JobStatus job_status); 76 void JobFinished(Job* job, MhtmlSaveStatus save_status);
77 77
78 // Called on the UI thread after the file got finalized and we have its size. 78 // Called on the UI thread after the file got finalized and we have its size.
79 void OnFileClosed(int job_id, JobStatus job_status, int64_t file_size); 79 void OnFileClosed(int job_id, MhtmlSaveStatus save_status, int64_t file_size);
80 80
81 // Creates and registers a new job. 81 // Creates and registers a new job.
82 Job* NewJob(WebContents* web_contents, 82 Job* NewJob(WebContents* web_contents,
83 const MHTMLGenerationParams& params, 83 const MHTMLGenerationParams& params,
84 const GenerateMHTMLCallback& callback); 84 const GenerateMHTMLCallback& callback);
85 85
86 // Finds job by id. Returns nullptr if no job with a given id was found. 86 // Finds job by id. Returns nullptr if no job with a given id was found.
87 Job* FindJob(int job_id); 87 Job* FindJob(int job_id);
88 88
89 // Called when the render process connected to a job exits. 89 // Called when the render process connected to a job exits.
90 void RenderProcessExited(Job* job); 90 void RenderProcessExited(Job* job);
91 91
92 std::map<int, std::unique_ptr<Job>> id_to_job_; 92 std::map<int, std::unique_ptr<Job>> id_to_job_;
93 93
94 int next_job_id_; 94 int next_job_id_;
95 95
96 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); 96 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager);
97 }; 97 };
98 98
99 } // namespace content 99 } // namespace content
100 100
101 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ 101 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698