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

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

Issue 19004: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/browser/download/save_file_manager.cc ('k') | chrome/browser/net/url_fetcher.h » ('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 "chrome/browser/download/save_package.h" 5 #include "chrome/browser/download/save_package.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 24 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
25 #include "chrome/browser/tab_contents/tab_util.h" 25 #include "chrome/browser/tab_contents/tab_util.h"
26 #include "chrome/browser/tab_contents/web_contents.h" 26 #include "chrome/browser/tab_contents/web_contents.h"
27 #include "chrome/browser/views/download_shelf_view.h" 27 #include "chrome/browser/views/download_shelf_view.h"
28 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/l10n_util.h" 29 #include "chrome/common/l10n_util.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "chrome/common/pref_service.h" 31 #include "chrome/common/pref_service.h"
32 #include "chrome/common/stl_util-inl.h" 32 #include "chrome/common/stl_util-inl.h"
33 #include "chrome/common/win_util.h" 33 #include "chrome/common/win_util.h"
34 #include "net/base/io_buffer.h"
34 #include "net/base/mime_util.h" 35 #include "net/base/mime_util.h"
35 #include "net/base/net_util.h" 36 #include "net/base/net_util.h"
36 #include "net/url_request/url_request_context.h" 37 #include "net/url_request/url_request_context.h"
37 #include "webkit/glue/dom_serializer_delegate.h" 38 #include "webkit/glue/dom_serializer_delegate.h"
38 39
39 #include "generated_resources.h" 40 #include "generated_resources.h"
40 41
41 using base::Time; 42 using base::Time;
42 43
43 namespace { 44 namespace {
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 806
806 std::wstring current_frame_url = UTF8ToWide(frame_url.spec()); 807 std::wstring current_frame_url = UTF8ToWide(frame_url.spec());
807 SaveUrlItemMap::iterator it = in_progress_items_.find(current_frame_url); 808 SaveUrlItemMap::iterator it = in_progress_items_.find(current_frame_url);
808 if (it == in_progress_items_.end()) 809 if (it == in_progress_items_.end())
809 return; 810 return;
810 SaveItem* save_item = it->second; 811 SaveItem* save_item = it->second;
811 DCHECK(save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM); 812 DCHECK(save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM);
812 813
813 if (!data.empty()) { 814 if (!data.empty()) {
814 // Prepare buffer for saving HTML data. 815 // Prepare buffer for saving HTML data.
815 char* new_data = static_cast<char*>(new char[data.size()]); 816 net::IOBuffer* new_data = new net::IOBuffer(data.size());
816 memcpy(new_data, data.data(), data.size()); 817 new_data->AddRef(); // We'll pass the buffer to SaveFileManager.
818 memcpy(new_data->data(), data.data(), data.size());
817 819
818 // Call write file functionality in file thread. 820 // Call write file functionality in file thread.
819 file_manager_->GetSaveLoop()->PostTask(FROM_HERE, 821 file_manager_->GetSaveLoop()->PostTask(FROM_HERE,
820 NewRunnableMethod(file_manager_, 822 NewRunnableMethod(file_manager_,
821 &SaveFileManager::UpdateSaveProgress, 823 &SaveFileManager::UpdateSaveProgress,
822 save_item->save_id(), 824 save_item->save_id(),
823 new_data, 825 new_data,
824 static_cast<int>(data.size()))); 826 static_cast<int>(data.size())));
825 } 827 }
826 828
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 1099
1098 if (available_length > dir_path_length) { 1100 if (available_length > dir_path_length) {
1099 *pure_file_name = 1101 *pure_file_name =
1100 pure_file_name->substr(0, available_length - dir_path_length); 1102 pure_file_name->substr(0, available_length - dir_path_length);
1101 return true; 1103 return true;
1102 } else { 1104 } else {
1103 pure_file_name->clear(); 1105 pure_file_name->clear();
1104 return false; 1106 return false;
1105 } 1107 }
1106 } 1108 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_file_manager.cc ('k') | chrome/browser/net/url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698