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

Side by Side Diff: chrome/browser/download/save_file_manager.cc

Issue 3581008: Fix instances of passing raw pointers to RefCounted objects in tasks. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Merge Created 10 years, 2 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
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/save_package.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/download/save_file_manager.h" 7 #include "chrome/browser/download/save_file_manager.h"
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 URLRequestContextGetter* request_context_getter, 124 URLRequestContextGetter* request_context_getter,
125 SavePackage* save_package) { 125 SavePackage* save_package) {
126 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 126 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
127 127
128 // Register a saving job. 128 // Register a saving job.
129 RegisterStartingRequest(url, save_package); 129 RegisterStartingRequest(url, save_package);
130 if (save_source == SaveFileCreateInfo::SAVE_FILE_FROM_NET) { 130 if (save_source == SaveFileCreateInfo::SAVE_FILE_FROM_NET) {
131 DCHECK(url.is_valid()); 131 DCHECK(url.is_valid());
132 132
133 ChromeThread::PostTask( 133 ChromeThread::PostTask(
134 ChromeThread::IO, FROM_HERE, 134 ChromeThread::IO,
135 NewRunnableMethod(this, 135 FROM_HERE,
136 &SaveFileManager::OnSaveURL, 136 NewRunnableMethod(
137 url, 137 this,
138 referrer, 138 &SaveFileManager::OnSaveURL,
139 render_process_host_id, 139 url,
140 render_view_id, 140 referrer,
141 request_context_getter)); 141 render_process_host_id,
142 render_view_id,
143 make_scoped_refptr(request_context_getter)));
142 } else { 144 } else {
143 // We manually start the save job. 145 // We manually start the save job.
144 SaveFileCreateInfo* info = new SaveFileCreateInfo(file_full_path, 146 SaveFileCreateInfo* info = new SaveFileCreateInfo(file_full_path,
145 url, 147 url,
146 save_source, 148 save_source,
147 -1); 149 -1);
148 info->render_process_id = render_process_host_id; 150 info->render_process_id = render_process_host_id;
149 info->render_view_id = render_view_id; 151 info->render_view_id = render_view_id;
150 152
151 // Since the data will come from render process, so we need to start 153 // Since the data will come from render process, so we need to start
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); 245 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
244 SaveFile* save_file = LookupSaveFile(save_id); 246 SaveFile* save_file = LookupSaveFile(save_id);
245 if (save_file) { 247 if (save_file) {
246 bool write_success = save_file->AppendDataToFile(data->data(), data_len); 248 bool write_success = save_file->AppendDataToFile(data->data(), data_len);
247 ChromeThread::PostTask( 249 ChromeThread::PostTask(
248 ChromeThread::UI, FROM_HERE, 250 ChromeThread::UI, FROM_HERE,
249 NewRunnableMethod( 251 NewRunnableMethod(
250 this, &SaveFileManager::OnUpdateSaveProgress, save_file->save_id(), 252 this, &SaveFileManager::OnUpdateSaveProgress, save_file->save_id(),
251 save_file->bytes_so_far(), write_success)); 253 save_file->bytes_so_far(), write_success));
252 } 254 }
253 data->Release();
254 } 255 }
255 256
256 // The IO thread will call this when saving is completed or it got error when 257 // The IO thread will call this when saving is completed or it got error when
257 // fetching data. In the former case, we forward the message to OnSaveFinished 258 // fetching data. In the former case, we forward the message to OnSaveFinished
258 // in UI thread. In the latter case, the save ID will be -1, which means the 259 // in UI thread. In the latter case, the save ID will be -1, which means the
259 // saving action did not even start, so we need to call OnErrorFinished in UI 260 // saving action did not even start, so we need to call OnErrorFinished in UI
260 // thread, which will use the save URL to find corresponding request record and 261 // thread, which will use the save URL to find corresponding request record and
261 // delete it. 262 // delete it.
262 void SaveFileManager::SaveFinished(int save_id, 263 void SaveFileManager::SaveFinished(int save_id,
263 GURL save_url, 264 GURL save_url,
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 SaveFileMap::iterator it = save_file_map_.find(*i); 525 SaveFileMap::iterator it = save_file_map_.find(*i);
525 if (it != save_file_map_.end()) { 526 if (it != save_file_map_.end()) {
526 SaveFile* save_file = it->second; 527 SaveFile* save_file = it->second;
527 DCHECK(!save_file->in_progress()); 528 DCHECK(!save_file->in_progress());
528 file_util::Delete(save_file->full_path(), false); 529 file_util::Delete(save_file->full_path(), false);
529 delete save_file; 530 delete save_file;
530 save_file_map_.erase(it); 531 save_file_map_.erase(it);
531 } 532 }
532 } 533 }
533 } 534 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698