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

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

Issue 3966007: Fix save file stuff to use scoped_refptr for refcounted params. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 DCHECK(url.is_valid()); 131 DCHECK(url.is_valid());
132 132
133 BrowserThread::PostTask( 133 BrowserThread::PostTask(
134 BrowserThread::IO, FROM_HERE, 134 BrowserThread::IO, FROM_HERE,
135 NewRunnableMethod(this, 135 NewRunnableMethod(this,
136 &SaveFileManager::OnSaveURL, 136 &SaveFileManager::OnSaveURL,
137 url, 137 url,
138 referrer, 138 referrer,
139 render_process_host_id, 139 render_process_host_id,
140 render_view_id, 140 render_view_id,
141 request_context_getter)); 141 make_scoped_refptr(request_context_getter)));
142 } else { 142 } else {
143 // We manually start the save job. 143 // We manually start the save job.
144 SaveFileCreateInfo* info = new SaveFileCreateInfo(file_full_path, 144 SaveFileCreateInfo* info = new SaveFileCreateInfo(file_full_path,
145 url, 145 url,
146 save_source, 146 save_source,
147 -1); 147 -1);
148 info->render_process_id = render_process_host_id; 148 info->render_process_id = render_process_host_id;
149 info->render_view_id = render_view_id; 149 info->render_view_id = render_view_id;
150 150
151 // Since the data will come from render process, so we need to start 151 // 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(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
244 SaveFile* save_file = LookupSaveFile(save_id); 244 SaveFile* save_file = LookupSaveFile(save_id);
245 if (save_file) { 245 if (save_file) {
246 bool write_success = save_file->AppendDataToFile(data->data(), data_len); 246 bool write_success = save_file->AppendDataToFile(data->data(), data_len);
247 BrowserThread::PostTask( 247 BrowserThread::PostTask(
248 BrowserThread::UI, FROM_HERE, 248 BrowserThread::UI, FROM_HERE,
249 NewRunnableMethod( 249 NewRunnableMethod(
250 this, &SaveFileManager::OnUpdateSaveProgress, save_file->save_id(), 250 this, &SaveFileManager::OnUpdateSaveProgress, save_file->save_id(),
251 save_file->bytes_so_far(), write_success)); 251 save_file->bytes_so_far(), write_success));
252 } 252 }
253 data->Release();
254 } 253 }
255 254
256 // The IO thread will call this when saving is completed or it got error when 255 // 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 256 // 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 257 // 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 258 // 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 259 // thread, which will use the save URL to find corresponding request record and
261 // delete it. 260 // delete it.
262 void SaveFileManager::SaveFinished(int save_id, 261 void SaveFileManager::SaveFinished(int save_id,
263 GURL save_url, 262 GURL save_url,
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 SaveFileMap::iterator it = save_file_map_.find(*i); 523 SaveFileMap::iterator it = save_file_map_.find(*i);
525 if (it != save_file_map_.end()) { 524 if (it != save_file_map_.end()) {
526 SaveFile* save_file = it->second; 525 SaveFile* save_file = it->second;
527 DCHECK(!save_file->in_progress()); 526 DCHECK(!save_file->in_progress());
528 file_util::Delete(save_file->full_path(), false); 527 file_util::Delete(save_file->full_path(), false);
529 delete save_file; 528 delete save_file;
530 save_file_map_.erase(it); 529 save_file_map_.erase(it);
531 } 530 }
532 } 531 }
533 } 532 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698