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

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

Issue 7044095: Hooking MHTML generation to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_
6 #define CHROME_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_
7
8 #include <map>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/platform_file.h"
12 #include "base/process.h"
13 #include "content/browser/browser_thread.h"
14 #include "ipc/ipc_platform_file.h"
15
16 class FilePath;
17 class TabContents;
18
19 class MHTMLGenerationManager
20 : public base::RefCountedThreadSafe<MHTMLGenerationManager,
21 BrowserThread::DeleteOnUIThread> {
22 public:
23 MHTMLGenerationManager();
24 ~MHTMLGenerationManager();
25
26 // Instructs the render view to generate a MHTML representation of the current
27 // page for |tab_contents|.
28 void GenerateMHTML(TabContents* tab_contents, const FilePath& file);
29
30 // Notification from the renderer that the MHTML generation succeeded/failed.
31 void MHTMLGenerated(int job_id, bool success);
32
33 // The details sent along with the MHTML_GENERATED notification.
34 struct NotificationDetails {
35 FilePath file_path;
36 bool success;
37 };
38
39 private:
40 struct Job{
41 Job();
42
43 FilePath file_path;
44
45 // The handles to file the MHTML is saved to, for the browser and renderer
46 // processes.
47 base::PlatformFile browser_file;
48 IPC::PlatformFileForTransit renderer_file;
49
50 // The IDs mapping to a specific tab.
51 int process_id;
52 int routing_id;
53 };
54
55 // Called on the file thread to create |file|.
56 void CreateFile(int job_id,
57 const FilePath& file,
58 base::ProcessHandle renderer_process);
59
60 // Called on the UI thread when the file that should hold the MHTML data has
61 // been created. This returns a handle to that file for the browser process
62 // and one for the renderer process. These handles are
63 // kInvalidPlatformFileValue if the file could not be opened.
64 void FileCreated(int job_id,
65 base::PlatformFile browser_file,
66 IPC::PlatformFileForTransit renderer_file);
67
68 // Called on the file thread to close the file the MHTML was saved to.
69 void CloseFile(base::PlatformFile file);
70
71 // Called on the UI thread when a job has been processed (successfully or
72 // not). Closes the file and removes the job from the job map.
73 void JobFinished(int job_id, bool success);
74
75 typedef std::map<int, Job> IDToJobMap;
76 IDToJobMap id_to_job_;
77
78 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationManager);
79 };
80
81 #endif // CHROME_BROWSER_DOWNLOAD_MHTML_GENERATION_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/mhtml_generation_browsertest.cc ('k') | chrome/browser/download/mhtml_generation_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698