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

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

Issue 8672001: Revert 111252 - Switch MHTMLGenerationManager to use a Callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "base/process.h" 12 #include "base/process.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "ipc/ipc_platform_file.h" 15 #include "ipc/ipc_platform_file.h"
16 16
17 class FilePath; 17 class FilePath;
18 class TabContents; 18 class TabContents;
19 19
20 class CONTENT_EXPORT MHTMLGenerationManager 20 class CONTENT_EXPORT MHTMLGenerationManager
21 : public base::RefCountedThreadSafe< 21 : public base::RefCountedThreadSafe<
22 MHTMLGenerationManager, content::BrowserThread::DeleteOnUIThread> { 22 MHTMLGenerationManager, content::BrowserThread::DeleteOnUIThread> {
23 public: 23 public:
24 MHTMLGenerationManager(); 24 MHTMLGenerationManager();
25 ~MHTMLGenerationManager(); 25 ~MHTMLGenerationManager();
26 26
27 typedef base::Callback<void(const FilePath& /* path to the MHTML file */,
28 int64 /* size of the file */)> GenerateMHTMLCallback;
29
30 // Instructs the render view to generate a MHTML representation of the current 27 // Instructs the render view to generate a MHTML representation of the current
31 // page for |tab_contents|. 28 // page for |tab_contents|.
32 void GenerateMHTML(TabContents* tab_contents, 29 void GenerateMHTML(TabContents* tab_contents, const FilePath& file);
33 const FilePath& file,
34 const GenerateMHTMLCallback& callback);
35 30
36 // Notification from the renderer that the MHTML generation finished. 31 // Notification from the renderer that the MHTML generation finished.
37 // |mhtml_data_size| contains the size in bytes of the generated MHTML data, 32 // |mhtml_data_size| contains the size in bytes of the generated MHTML data,
38 // or -1 in case of failure. 33 // or -1 in case of failure.
39 void MHTMLGenerated(int job_id, int64 mhtml_data_size); 34 void MHTMLGenerated(int job_id, int64 mhtml_data_size);
40 35
36 // The details sent along with the MHTML_GENERATED notification.
37 struct NotificationDetails {
38 FilePath file_path;
39 int64 file_size;
40 };
41
41 private: 42 private:
42 struct Job{ 43 struct Job{
43 Job(); 44 Job();
44 45
45 FilePath file_path; 46 FilePath file_path;
46 47
47 // The handles to file the MHTML is saved to, for the browser and renderer 48 // The handles to file the MHTML is saved to, for the browser and renderer
48 // processes. 49 // processes.
49 base::PlatformFile browser_file; 50 base::PlatformFile browser_file;
50 IPC::PlatformFileForTransit renderer_file; 51 IPC::PlatformFileForTransit renderer_file;
51 52
52 // The IDs mapping to a specific tab. 53 // The IDs mapping to a specific tab.
53 int process_id; 54 int process_id;
54 int routing_id; 55 int routing_id;
55
56 // The callback to call once generation is complete.
57 GenerateMHTMLCallback callback;
58 }; 56 };
59 57
60 // Called on the file thread to create |file|. 58 // Called on the file thread to create |file|.
61 void CreateFile(int job_id, 59 void CreateFile(int job_id,
62 const FilePath& file, 60 const FilePath& file,
63 base::ProcessHandle renderer_process); 61 base::ProcessHandle renderer_process);
64 62
65 // Called on the UI thread when the file that should hold the MHTML data has 63 // Called on the UI thread when the file that should hold the MHTML data has
66 // been created. This returns a handle to that file for the browser process 64 // been created. This returns a handle to that file for the browser process
67 // and one for the renderer process. These handles are 65 // and one for the renderer process. These handles are
(...skipping 10 matching lines...) Expand all
78 // |mhtml_data_size| is -1 if the MHTML generation failed. 76 // |mhtml_data_size| is -1 if the MHTML generation failed.
79 void JobFinished(int job_id, int64 mhtml_data_size); 77 void JobFinished(int job_id, int64 mhtml_data_size);
80 78
81 typedef std::map<int, Job> IDToJobMap; 79 typedef std::map<int, Job> IDToJobMap;
82 IDToJobMap id_to_job_; 80 IDToJobMap id_to_job_;
83 81
84 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager); 82 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager);
85 }; 83 };
86 84
87 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_ 85 #endif // CONTENT_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/download/mhtml_generation_browsertest.cc ('k') | content/browser/download/mhtml_generation_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698