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

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

Issue 8556001: Convert NewRunnableFunction/NewRunnableMethod calls to use base::Bind(). (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 #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/platform_file.h" 8 #include "base/platform_file.h"
8 #include "content/browser/renderer_host/render_process_host.h" 9 #include "content/browser/renderer_host/render_process_host.h"
9 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
10 #include "content/browser/tab_contents/tab_contents.h" 11 #include "content/browser/tab_contents/tab_contents.h"
11 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
12 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
13 #include "content/public/browser/notification_types.h" 14 #include "content/public/browser/notification_types.h"
14 15
15 using content::BrowserThread; 16 using content::BrowserThread;
16 17
(...skipping 18 matching lines...) Expand all
35 int job_id = id_counter++; 36 int job_id = id_counter++;
36 Job job; 37 Job job;
37 job.file_path = file; 38 job.file_path = file;
38 job.process_id = tab_contents->GetRenderProcessHost()->id(); 39 job.process_id = tab_contents->GetRenderProcessHost()->id();
39 job.routing_id = tab_contents->render_view_host()->routing_id(); 40 job.routing_id = tab_contents->render_view_host()->routing_id();
40 id_to_job_[job_id] = job; 41 id_to_job_[job_id] = job;
41 42
42 base::ProcessHandle renderer_process = 43 base::ProcessHandle renderer_process =
43 tab_contents->GetRenderProcessHost()->GetHandle(); 44 tab_contents->GetRenderProcessHost()->GetHandle();
44 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 45 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
45 NewRunnableMethod(this, &MHTMLGenerationManager::CreateFile, 46 base::Bind(&MHTMLGenerationManager::CreateFile, this,
46 job_id, file, renderer_process)); 47 job_id, file, renderer_process));
47 } 48 }
48 49
49 void MHTMLGenerationManager::MHTMLGenerated(int job_id, int64 mhtml_data_size) { 50 void MHTMLGenerationManager::MHTMLGenerated(int job_id, int64 mhtml_data_size) {
50 JobFinished(job_id, mhtml_data_size); 51 JobFinished(job_id, mhtml_data_size);
51 } 52 }
52 53
53 void MHTMLGenerationManager::CreateFile(int job_id, const FilePath& file_path, 54 void MHTMLGenerationManager::CreateFile(int job_id, const FilePath& file_path,
54 base::ProcessHandle renderer_process) { 55 base::ProcessHandle renderer_process) {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
56 base::PlatformFile browser_file = base::CreatePlatformFile(file_path, 57 base::PlatformFile browser_file = base::CreatePlatformFile(file_path,
57 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE, 58 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE,
58 NULL, NULL); 59 NULL, NULL);
59 if (browser_file == base::kInvalidPlatformFileValue) { 60 if (browser_file == base::kInvalidPlatformFileValue) {
60 LOG(ERROR) << "Failed to create file to save MHTML at: " << 61 LOG(ERROR) << "Failed to create file to save MHTML at: " <<
61 file_path.value(); 62 file_path.value();
62 } 63 }
63 64
64 IPC::PlatformFileForTransit renderer_file = 65 IPC::PlatformFileForTransit renderer_file =
65 IPC::GetFileHandleForProcess(browser_file, renderer_process, false); 66 IPC::GetFileHandleForProcess(browser_file, renderer_process, false);
66 67
67 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 68 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
68 NewRunnableMethod(this, &MHTMLGenerationManager::FileCreated, 69 base::Bind(&MHTMLGenerationManager::FileCreated, this,
69 job_id, browser_file, renderer_file)); 70 job_id, browser_file, renderer_file));
70 } 71 }
71 72
72 void MHTMLGenerationManager::FileCreated(int job_id, 73 void MHTMLGenerationManager::FileCreated(int job_id,
73 base::PlatformFile browser_file, 74 base::PlatformFile browser_file,
74 IPC::PlatformFileForTransit renderer_file) { 75 IPC::PlatformFileForTransit renderer_file) {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
76 if (browser_file == base::kInvalidPlatformFileValue) { 77 if (browser_file == base::kInvalidPlatformFileValue) {
77 LOG(ERROR) << "Failed to create file"; 78 LOG(ERROR) << "Failed to create file";
78 JobFinished(job_id, -1); 79 JobFinished(job_id, -1);
79 return; 80 return;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 details.file_path = job.file_path; 116 details.file_path = job.file_path;
116 details.file_size = file_size; 117 details.file_size = file_size;
117 118
118 content::NotificationService::current()->Notify( 119 content::NotificationService::current()->Notify(
119 content::NOTIFICATION_MHTML_GENERATED, 120 content::NOTIFICATION_MHTML_GENERATED,
120 content::Source<RenderViewHost>(rvh), 121 content::Source<RenderViewHost>(rvh),
121 content::Details<NotificationDetails>(&details)); 122 content::Details<NotificationDetails>(&details));
122 } 123 }
123 124
124 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 125 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
125 NewRunnableMethod(this, &MHTMLGenerationManager::CloseFile, 126 base::Bind(&MHTMLGenerationManager::CloseFile, this, job.browser_file));
126 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 }
OLDNEW
« no previous file with comments | « content/browser/download/drag_download_util.cc ('k') | content/browser/net/url_request_failed_dns_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698