diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 01:56:32 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 01:56:32 +0000 |
commit | f6b4853153c6be7a7ce092d4c5f3172c022da561 (patch) | |
tree | 99f03bfa0866d1441f37f979d88c82f3fb51180f /chrome/browser/download/save_file_manager.cc | |
parent | 5e5136c2a2fc497ada68dadfacfd9068ee22f36f (diff) | |
download | chromium_src-f6b4853153c6be7a7ce092d4c5f3172c022da561.zip chromium_src-f6b4853153c6be7a7ce092d4c5f3172c022da561.tar.gz chromium_src-f6b4853153c6be7a7ce092d4c5f3172c022da561.tar.bz2 |
Change url wstrings to GURLS
Review URL: http://codereview.chromium.org/20273
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/save_file_manager.cc')
-rw-r--r-- | chrome/browser/download/save_file_manager.cc | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/chrome/browser/download/save_file_manager.cc b/chrome/browser/download/save_file_manager.cc index 64984de..510b94c 100644 --- a/chrome/browser/download/save_file_manager.cc +++ b/chrome/browser/download/save_file_manager.cc @@ -87,7 +87,7 @@ int SaveFileManager::GetNextId() { return next_id_++; } -void SaveFileManager::RegisterStartingRequest(const std::wstring& save_url, +void SaveFileManager::RegisterStartingRequest(const GURL& save_url, SavePackage* save_package) { // Make sure it runs in the UI thread. DCHECK(MessageLoop::current() == ui_loop_); @@ -96,19 +96,19 @@ void SaveFileManager::RegisterStartingRequest(const std::wstring& save_url, // Register this starting request. StartingRequestsMap& starting_requests = tab_starting_requests_[tab_id]; bool never_present = starting_requests.insert( - StartingRequestsMap::value_type(save_url, save_package)).second; + StartingRequestsMap::value_type(save_url.spec(), save_package)).second; DCHECK(never_present); } SavePackage* SaveFileManager::UnregisterStartingRequest( - const std::wstring& save_url, int tab_id) { + const GURL& save_url, int tab_id) { // Make sure it runs in UI thread. DCHECK(MessageLoop::current() == ui_loop_); TabToStartingRequestsMap::iterator it = tab_starting_requests_.find(tab_id); if (it != tab_starting_requests_.end()) { StartingRequestsMap& requests = it->second; - StartingRequestsMap::iterator sit = requests.find(save_url); + StartingRequestsMap::iterator sit = requests.find(save_url.spec()); if (sit == requests.end()) return NULL; @@ -149,8 +149,8 @@ SavePackage* SaveFileManager::LookupPackage(int save_id) { } // Call from SavePackage for starting a saving job -void SaveFileManager::SaveURL(const std::wstring& url, - const std::wstring& referrer, +void SaveFileManager::SaveURL(const GURL& url, + const GURL& referrer, int render_process_host_id, int render_view_id, SaveFileCreateInfo::SaveFileSource save_source, @@ -166,14 +166,13 @@ void SaveFileManager::SaveURL(const std::wstring& url, // Register a saving job. RegisterStartingRequest(url, save_package); if (save_source == SaveFileCreateInfo::SAVE_FILE_FROM_NET) { - GURL save_url(url); - DCHECK(save_url.is_valid()); + DCHECK(url.is_valid()); io_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, &SaveFileManager::OnSaveURL, - save_url, - GURL(referrer), + url, + referrer, render_process_host_id, render_view_id, request_context)); @@ -195,7 +194,7 @@ void SaveFileManager::SaveURL(const std::wstring& url, // If the save id is -1, it means we just send a request to save, but the // saving action has still not happened, need to call UnregisterStartingRequest // to remove it from the tracking map. -void SaveFileManager::RemoveSaveFile(int save_id, const std::wstring& save_url, +void SaveFileManager::RemoveSaveFile(int save_id, const GURL& save_url, SavePackage* package) { DCHECK(MessageLoop::current() == ui_loop_ && package); // A save page job(SavePackage) can only have one manager, @@ -295,7 +294,7 @@ void SaveFileManager::UpdateSaveProgress(int save_id, // thread, which will use the save URL to find corresponding request record and // delete it. void SaveFileManager::SaveFinished(int save_id, - std::wstring save_url, + GURL save_url, int render_process_id, bool is_success) { DCHECK(MessageLoop::current() == GetSaveLoop()); @@ -312,7 +311,7 @@ void SaveFileManager::SaveFinished(int save_id, save_file->Finish(); } else if (save_id == -1) { // Before saving started, we got error. We still call finish process. - DCHECK(!save_url.empty()); + DCHECK(!save_url.is_empty()); ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, &SaveFileManager::OnErrorFinished, @@ -375,7 +374,7 @@ void SaveFileManager::OnSaveFinished(int save_id, package->SaveFinished(save_id, bytes_so_far, is_success); } -void SaveFileManager::OnErrorFinished(std::wstring save_url, int tab_id) { +void SaveFileManager::OnErrorFinished(GURL save_url, int tab_id) { DCHECK(MessageLoop::current() == ui_loop_); SavePackage* save_package = UnregisterStartingRequest(save_url, tab_id); if (save_package) @@ -473,7 +472,7 @@ void SaveFileManager::CancelSave(int save_id) { // It is possible that SaveItem which has specified save_id has been canceled // before this function runs. So if we can not find corresponding SaveFile by // using specified save_id, just return. -void SaveFileManager::SaveLocalFile(const std::wstring& original_file_url, +void SaveFileManager::SaveLocalFile(const GURL& original_file_url, int save_id, int render_process_id) { DCHECK(MessageLoop::current() == GetSaveLoop()); @@ -488,10 +487,9 @@ void SaveFileManager::SaveLocalFile(const std::wstring& original_file_url, // Close the save file before the copy operation. save_file->Finish(); - GURL file_url(original_file_url); - DCHECK(file_url.SchemeIsFile()); - std::wstring file_path; - net::FileURLToFilePath(file_url, &file_path); + DCHECK(original_file_url.SchemeIsFile()); + FilePath file_path; + net::FileURLToFilePath(original_file_url, &file_path); // If we can not get valid file path from original URL, treat it as // disk error. if (file_path.empty()) @@ -499,8 +497,8 @@ void SaveFileManager::SaveLocalFile(const std::wstring& original_file_url, // Copy the local file to the temporary file. It will be renamed to its // final name later. - bool success = CopyFile(file_path.c_str(), - save_file->full_path().c_str(), FALSE) != 0; + bool success = file_util::CopyFile(file_path, + FilePath::FromWStringHack(save_file->full_path())); if (!success) file_util::Delete(save_file->full_path(), false); SaveFinished(save_id, original_file_url, render_process_id, success); |