OLD | NEW |
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 #include "content/browser/download/mhtml_generation_manager.h" | 5 #include "content/browser/download/mhtml_generation_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
9 #include "content/browser/renderer_host/render_process_host.h" | 9 #include "content/browser/renderer_host/render_process_host_impl.h" |
10 #include "content/browser/renderer_host/render_view_host.h" | 10 #include "content/browser/renderer_host/render_view_host.h" |
11 #include "content/browser/tab_contents/tab_contents.h" | 11 #include "content/browser/tab_contents/tab_contents.h" |
12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
13 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
14 #include "content/public/browser/notification_types.h" | 14 #include "content/public/browser/notification_types.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
17 | 17 |
18 MHTMLGenerationManager::Job::Job() | 18 MHTMLGenerationManager::Job::Job() |
19 : browser_file(base::kInvalidPlatformFileValue), | 19 : browser_file(base::kInvalidPlatformFileValue), |
20 renderer_file(IPC::InvalidPlatformFileForTransit()), | 20 renderer_file(IPC::InvalidPlatformFileForTransit()), |
21 process_id(-1), | 21 process_id(-1), |
22 routing_id(-1) { | 22 routing_id(-1) { |
23 } | 23 } |
24 | 24 |
25 MHTMLGenerationManager::MHTMLGenerationManager() { | 25 MHTMLGenerationManager::MHTMLGenerationManager() { |
26 } | 26 } |
27 | 27 |
28 MHTMLGenerationManager::~MHTMLGenerationManager() { | 28 MHTMLGenerationManager::~MHTMLGenerationManager() { |
29 } | 29 } |
30 | 30 |
31 void MHTMLGenerationManager::GenerateMHTML(TabContents* tab_contents, | 31 void MHTMLGenerationManager::GenerateMHTML(TabContents* tab_contents, |
32 const FilePath& file) { | 32 const FilePath& file) { |
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
34 static int id_counter = 0; | 34 static int id_counter = 0; |
35 | 35 |
36 int job_id = id_counter++; | 36 int job_id = id_counter++; |
37 Job job; | 37 Job job; |
38 job.file_path = file; | 38 job.file_path = file; |
39 job.process_id = tab_contents->GetRenderProcessHost()->id(); | 39 job.process_id = tab_contents->GetRenderProcessHost()->GetID(); |
40 job.routing_id = tab_contents->render_view_host()->routing_id(); | 40 job.routing_id = tab_contents->render_view_host()->routing_id(); |
41 id_to_job_[job_id] = job; | 41 id_to_job_[job_id] = job; |
42 | 42 |
43 base::ProcessHandle renderer_process = | 43 base::ProcessHandle renderer_process = |
44 tab_contents->GetRenderProcessHost()->GetHandle(); | 44 tab_contents->GetRenderProcessHost()->GetHandle(); |
45 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 45 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
46 base::Bind(&MHTMLGenerationManager::CreateFile, this, | 46 base::Bind(&MHTMLGenerationManager::CreateFile, this, |
47 job_id, file, renderer_process)); | 47 job_id, file, renderer_process)); |
48 } | 48 } |
49 | 49 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 125 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
126 base::Bind(&MHTMLGenerationManager::CloseFile, this, job.browser_file)); | 126 base::Bind(&MHTMLGenerationManager::CloseFile, this, job.browser_file)); |
127 | 127 |
128 id_to_job_.erase(job_id); | 128 id_to_job_.erase(job_id); |
129 } | 129 } |
130 | 130 |
131 void MHTMLGenerationManager::CloseFile(base::PlatformFile file) { | 131 void MHTMLGenerationManager::CloseFile(base::PlatformFile file) { |
132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
133 base::ClosePlatformFile(file); | 133 base::ClosePlatformFile(file); |
134 } | 134 } |
OLD | NEW |