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

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

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Move MHTMLExtraData and MHTMLExtraPart out of the .h file Created 3 years, 9 months 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 "base/supports_user_data.h"
18 #include "content/common/download/mhtml_save_status.h" 19 #include "content/common/download/mhtml_save_status.h"
20 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/mhtml_generation_params.h" 21 #include "content/public/common/mhtml_generation_params.h"
20 #include "ipc/ipc_platform_file.h" 22 #include "ipc/ipc_platform_file.h"
21 23
22 namespace base { 24 namespace base {
23 class FilePath; 25 class FilePath;
24 } 26 }
25 27
26 namespace content { 28 namespace content {
27 29
28 class RenderFrameHostImpl; 30 class RenderFrameHostImpl;
29 class WebContents; 31 class WebContents;
30 32
31 // The class and all of its members live on the UI thread. Only static methods 33 // The class and all of its members live on the UI thread. Only static methods
32 // are executed on other threads. 34 // are executed on other threads.
33 // 35 //
34 // MHTMLGenerationManager is a singleton. Each call to SaveMHTML method creates 36 // MHTMLGenerationManager is a singleton. Each call to SaveMHTML method creates
35 // a new instance of MHTMLGenerationManager::Job that tracks generation of a 37 // a new instance of MHTMLGenerationManager::Job that tracks generation of a
36 // single MHTML file. 38 // single MHTML file.
37 class MHTMLGenerationManager { 39 class CONTENT_EXPORT MHTMLGenerationManager {
38 public: 40 public:
39 static MHTMLGenerationManager* GetInstance(); 41 static MHTMLGenerationManager* GetInstance();
40 42
41 // GenerateMHTMLCallback is called to report completion and status of MHTML 43 // GenerateMHTMLCallback is called to report completion and status of MHTML
42 // generation. On success |file_size| indicates the size of the 44 // generation. On success |file_size| indicates the size of the
43 // generated file. On failure |file_size| is -1. 45 // generated file. On failure |file_size| is -1.
44 typedef base::Callback<void(int64_t file_size)> GenerateMHTMLCallback; 46 typedef base::Callback<void(int64_t file_size)> GenerateMHTMLCallback;
45 47
46 // Instructs the RenderFrames in |web_contents| to generate a MHTML 48 // Instructs the RenderFrames in |web_contents| to generate a MHTML
47 // representation of the current page. 49 // representation of the current page.
48 void SaveMHTML(WebContents* web_contents, 50 void SaveMHTML(WebContents* web_contents,
49 const MHTMLGenerationParams& params, 51 const MHTMLGenerationParams& params,
50 const GenerateMHTMLCallback& callback); 52 const GenerateMHTMLCallback& callback);
51 53
52 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the 54 // Handler for FrameHostMsg_SerializeAsMHTMLResponse (a notification from the
53 // renderer that the MHTML generation finished for a single frame). 55 // renderer that the MHTML generation finished for a single frame).
54 void OnSerializeAsMHTMLResponse( 56 void OnSerializeAsMHTMLResponse(
55 RenderFrameHostImpl* sender, 57 RenderFrameHostImpl* sender,
56 int job_id, 58 int job_id,
57 MhtmlSaveStatus save_status, 59 MhtmlSaveStatus save_status,
58 const std::set<std::string>& digests_of_uris_of_serialized_resources, 60 const std::set<std::string>& digests_of_uris_of_serialized_resources,
59 base::TimeDelta renderer_main_thread_time); 61 base::TimeDelta renderer_main_thread_time);
60 62
63 // Add an extra MHTML part to the data structure stored by the WebContents.
64 // This will take care of generating the boundary line. This will also set
65 // the content-type and content-location headers to the values provided, and
66 // use the body provided.
67 static void StashMHTMLPartForAdditionToPage(
68 content::WebContents* contents,
69 const std::string& content_type,
70 const std::string& content_location,
71 const std::string& body);
72
61 private: 73 private:
62 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>; 74 friend struct base::DefaultSingletonTraits<MHTMLGenerationManager>;
63 class Job; 75 class Job;
64 76
65 MHTMLGenerationManager(); 77 MHTMLGenerationManager();
66 virtual ~MHTMLGenerationManager(); 78 virtual ~MHTMLGenerationManager();
67 79
68 // Called on the file thread to create |file|. 80 // Called on the file thread to create |file|.
69 static base::File CreateFile(const base::FilePath& file_path); 81 static base::File CreateFile(const base::FilePath& file_path);
70 82
(...skipping 23 matching lines...) Expand all
94 std::map<int, std::unique_ptr<Job>> id_to_job_; 106 std::map<int, std::unique_ptr<Job>> id_to_job_;
95 107
96 int next_job_id_; 108 int next_job_id_;
97 109
98 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); 110 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager);
99 }; 111 };
100 112
101 } // namespace content 113 } // namespace content
102 114
103 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ 115 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698