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

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

Issue 9369009: Make content::ResourceContext be a real interface like the rest of the Content API (i.e. don't ha... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 8 years, 10 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
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "content/browser/download/save_file_manager.h" 7 #include "content/browser/download/save_file_manager.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 // Call from SavePackage for starting a saving job 114 // Call from SavePackage for starting a saving job
115 void SaveFileManager::SaveURL( 115 void SaveFileManager::SaveURL(
116 const GURL& url, 116 const GURL& url,
117 const GURL& referrer, 117 const GURL& referrer,
118 int render_process_host_id, 118 int render_process_host_id,
119 int render_view_id, 119 int render_view_id,
120 SaveFileCreateInfo::SaveFileSource save_source, 120 SaveFileCreateInfo::SaveFileSource save_source,
121 const FilePath& file_full_path, 121 const FilePath& file_full_path,
122 const content::ResourceContext& context, 122 content::ResourceContext* context,
123 SavePackage* save_package) { 123 SavePackage* save_package) {
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
125 125
126 // Register a saving job. 126 // Register a saving job.
127 RegisterStartingRequest(url, save_package); 127 RegisterStartingRequest(url, save_package);
128 if (save_source == SaveFileCreateInfo::SAVE_FILE_FROM_NET) { 128 if (save_source == SaveFileCreateInfo::SAVE_FILE_FROM_NET) {
129 DCHECK(url.is_valid()); 129 DCHECK(url.is_valid());
130 130
131 BrowserThread::PostTask( 131 BrowserThread::PostTask(
132 BrowserThread::IO, FROM_HERE, 132 BrowserThread::IO, FROM_HERE,
133 base::Bind(&SaveFileManager::OnSaveURL, this, url, referrer, 133 base::Bind(&SaveFileManager::OnSaveURL, this, url, referrer,
134 render_process_host_id, render_view_id, &context)); 134 render_process_host_id, render_view_id, context));
135 } else { 135 } else {
136 // We manually start the save job. 136 // We manually start the save job.
137 SaveFileCreateInfo* info = new SaveFileCreateInfo(file_full_path, 137 SaveFileCreateInfo* info = new SaveFileCreateInfo(file_full_path,
138 url, 138 url,
139 save_source, 139 save_source,
140 -1); 140 -1);
141 info->render_process_id = render_process_host_id; 141 info->render_process_id = render_process_host_id;
142 info->render_view_id = render_view_id; 142 info->render_view_id = render_view_id;
143 143
144 // Since the data will come from render process, so we need to start 144 // Since the data will come from render process, so we need to start
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 save_package->SaveFailed(save_url); 349 save_package->SaveFailed(save_url);
350 } 350 }
351 351
352 // Notifications sent from the UI thread and run on the IO thread. 352 // Notifications sent from the UI thread and run on the IO thread.
353 353
354 void SaveFileManager::OnSaveURL( 354 void SaveFileManager::OnSaveURL(
355 const GURL& url, 355 const GURL& url,
356 const GURL& referrer, 356 const GURL& referrer,
357 int render_process_host_id, 357 int render_process_host_id,
358 int render_view_id, 358 int render_view_id,
359 const content::ResourceContext* context) { 359 content::ResourceContext* context) {
360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
361 resource_dispatcher_host_->BeginSaveFile(url, 361 resource_dispatcher_host_->BeginSaveFile(url,
362 referrer, 362 referrer,
363 render_process_host_id, 363 render_process_host_id,
364 render_view_id, 364 render_view_id,
365 *context); 365 context);
366 } 366 }
367 367
368 void SaveFileManager::OnRequireSaveJobFromOtherSource( 368 void SaveFileManager::OnRequireSaveJobFromOtherSource(
369 SaveFileCreateInfo* info) { 369 SaveFileCreateInfo* info) {
370 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 370 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
371 DCHECK_EQ(info->save_id, -1); 371 DCHECK_EQ(info->save_id, -1);
372 // Generate a unique save id. 372 // Generate a unique save id.
373 info->save_id = GetNextId(); 373 info->save_id = GetNextId();
374 // Start real saving action. 374 // Start real saving action.
375 BrowserThread::PostTask( 375 BrowserThread::PostTask(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 SaveFileMap::iterator it = save_file_map_.find(*i); 515 SaveFileMap::iterator it = save_file_map_.find(*i);
516 if (it != save_file_map_.end()) { 516 if (it != save_file_map_.end()) {
517 SaveFile* save_file = it->second; 517 SaveFile* save_file = it->second;
518 DCHECK(!save_file->InProgress()); 518 DCHECK(!save_file->InProgress());
519 file_util::Delete(save_file->FullPath(), false); 519 file_util::Delete(save_file->FullPath(), false);
520 delete save_file; 520 delete save_file;
521 save_file_map_.erase(it); 521 save_file_map_.erase(it);
522 } 522 }
523 } 523 }
524 } 524 }
OLDNEW
« no previous file with comments | « content/browser/download/save_file_manager.h ('k') | content/browser/mock_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698