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/platform_file.h" | 7 #include "base/platform_file.h" |
8 #include "content/browser/renderer_host/render_process_host.h" | 8 #include "content/browser/renderer_host/render_process_host.h" |
9 #include "content/browser/renderer_host/render_view_host.h" | 9 #include "content/browser/renderer_host/render_view_host.h" |
10 #include "content/browser/tab_contents/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
11 #include "content/common/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
13 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
14 | 14 |
15 MHTMLGenerationManager::Job::Job() | 15 MHTMLGenerationManager::Job::Job() |
16 : browser_file(base::kInvalidPlatformFileValue), | 16 : browser_file(base::kInvalidPlatformFileValue), |
17 renderer_file(IPC::InvalidPlatformFileForTransit()), | 17 renderer_file(IPC::InvalidPlatformFileForTransit()), |
18 process_id(-1), | 18 process_id(-1), |
19 routing_id(-1) { | 19 routing_id(-1) { |
20 } | 20 } |
21 | 21 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 Job& job = iter->second; | 108 Job& job = iter->second; |
109 | 109 |
110 RenderViewHost* rvh = RenderViewHost::FromID(job.process_id, job.routing_id); | 110 RenderViewHost* rvh = RenderViewHost::FromID(job.process_id, job.routing_id); |
111 if (rvh) { | 111 if (rvh) { |
112 NotificationDetails details; | 112 NotificationDetails details; |
113 details.file_path = job.file_path; | 113 details.file_path = job.file_path; |
114 details.file_size = file_size; | 114 details.file_size = file_size; |
115 | 115 |
116 NotificationService::current()->Notify( | 116 content::NotificationService::current()->Notify( |
117 content::NOTIFICATION_MHTML_GENERATED, | 117 content::NOTIFICATION_MHTML_GENERATED, |
118 content::Source<RenderViewHost>(rvh), | 118 content::Source<RenderViewHost>(rvh), |
119 content::Details<NotificationDetails>(&details)); | 119 content::Details<NotificationDetails>(&details)); |
120 } | 120 } |
121 | 121 |
122 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 122 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
123 NewRunnableMethod(this, &MHTMLGenerationManager::CloseFile, | 123 NewRunnableMethod(this, &MHTMLGenerationManager::CloseFile, |
124 job.browser_file)); | 124 job.browser_file)); |
125 | 125 |
126 id_to_job_.erase(job_id); | 126 id_to_job_.erase(job_id); |
127 } | 127 } |
128 | 128 |
129 void MHTMLGenerationManager::CloseFile(base::PlatformFile file) { | 129 void MHTMLGenerationManager::CloseFile(base::PlatformFile file) { |
130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
131 base::ClosePlatformFile(file); | 131 base::ClosePlatformFile(file); |
132 } | 132 } |
OLD | NEW |