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

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

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 "content/browser/download/save_package.h" 5 #include "content/browser/download/save_package.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/i18n/file_util_icu.h" 12 #include "base/i18n/file_util_icu.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/string_piece.h" 16 #include "base/string_piece.h"
17 #include "base/string_split.h" 17 #include "base/string_split.h"
18 #include "base/sys_string_conversions.h" 18 #include "base/sys_string_conversions.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "content/browser/browser_context.h" 21 #include "content/browser/browser_context.h"
22 #include "content/browser/download/download_file_manager.h" 22 #include "content/browser/download/download_file_manager.h"
23 #include "content/browser/download/download_item.h" 23 #include "content/browser/download/download_item.h"
24 #include "content/browser/download/download_manager.h" 24 #include "content/browser/download/download_manager.h"
25 #include "content/browser/download/save_file.h" 25 #include "content/browser/download/save_file.h"
26 #include "content/browser/download/save_file_manager.h" 26 #include "content/browser/download/save_file_manager.h"
27 #include "content/browser/download/save_item.h" 27 #include "content/browser/download/save_item.h"
28 #include "content/browser/renderer_host/render_process_host.h" 28 #include "content/browser/renderer_host/render_process_host_impl.h"
29 #include "content/browser/renderer_host/render_view_host.h" 29 #include "content/browser/renderer_host/render_view_host.h"
30 #include "content/browser/renderer_host/render_view_host_delegate.h" 30 #include "content/browser/renderer_host/render_view_host_delegate.h"
31 #include "content/browser/renderer_host/resource_dispatcher_host.h" 31 #include "content/browser/renderer_host/resource_dispatcher_host.h"
32 #include "content/browser/resource_context.h" 32 #include "content/browser/resource_context.h"
33 #include "content/browser/tab_contents/tab_contents.h" 33 #include "content/browser/tab_contents/tab_contents.h"
34 #include "content/common/view_messages.h" 34 #include "content/common/view_messages.h"
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/content_browser_client.h" 36 #include "content/public/browser/content_browser_client.h"
37 #include "content/public/browser/download_manager_delegate.h" 37 #include "content/public/browser/download_manager_delegate.h"
38 #include "content/public/common/url_constants.h" 38 #include "content/public/common/url_constants.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 page_url_(GetUrlToBeSaved()), 122 page_url_(GetUrlToBeSaved()),
123 saved_main_file_path_(file_full_path), 123 saved_main_file_path_(file_full_path),
124 saved_main_directory_path_(directory_full_path), 124 saved_main_directory_path_(directory_full_path),
125 title_(tab_contents->GetTitle()), 125 title_(tab_contents->GetTitle()),
126 finished_(false), 126 finished_(false),
127 user_canceled_(false), 127 user_canceled_(false),
128 disk_error_occurred_(false), 128 disk_error_occurred_(false),
129 save_type_(save_type), 129 save_type_(save_type),
130 all_save_items_count_(0), 130 all_save_items_count_(0),
131 wait_state_(INITIALIZE), 131 wait_state_(INITIALIZE),
132 tab_id_(tab_contents->GetRenderProcessHost()->id()), 132 tab_id_(tab_contents->GetRenderProcessHost()->GetID()),
133 unique_id_(g_save_package_id++), 133 unique_id_(g_save_package_id++),
134 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 134 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
135 DCHECK(page_url_.is_valid()); 135 DCHECK(page_url_.is_valid());
136 DCHECK(save_type_ == SAVE_AS_ONLY_HTML || 136 DCHECK(save_type_ == SAVE_AS_ONLY_HTML ||
137 save_type_ == SAVE_AS_COMPLETE_HTML); 137 save_type_ == SAVE_AS_COMPLETE_HTML);
138 DCHECK(!saved_main_file_path_.empty() && 138 DCHECK(!saved_main_file_path_.empty() &&
139 saved_main_file_path_.value().length() <= kMaxFilePathLength); 139 saved_main_file_path_.value().length() <= kMaxFilePathLength);
140 DCHECK(!saved_main_directory_path_.empty() && 140 DCHECK(!saved_main_directory_path_.empty() &&
141 saved_main_directory_path_.value().length() < kMaxFilePathLength); 141 saved_main_directory_path_.value().length() < kMaxFilePathLength);
142 InternalInit(); 142 InternalInit();
143 } 143 }
144 144
145 SavePackage::SavePackage(TabContents* tab_contents) 145 SavePackage::SavePackage(TabContents* tab_contents)
146 : TabContentsObserver(tab_contents), 146 : TabContentsObserver(tab_contents),
147 file_manager_(NULL), 147 file_manager_(NULL),
148 download_manager_(NULL), 148 download_manager_(NULL),
149 download_(NULL), 149 download_(NULL),
150 page_url_(GetUrlToBeSaved()), 150 page_url_(GetUrlToBeSaved()),
151 title_(tab_contents->GetTitle()), 151 title_(tab_contents->GetTitle()),
152 finished_(false), 152 finished_(false),
153 user_canceled_(false), 153 user_canceled_(false),
154 disk_error_occurred_(false), 154 disk_error_occurred_(false),
155 save_type_(SAVE_TYPE_UNKNOWN), 155 save_type_(SAVE_TYPE_UNKNOWN),
156 all_save_items_count_(0), 156 all_save_items_count_(0),
157 wait_state_(INITIALIZE), 157 wait_state_(INITIALIZE),
158 tab_id_(tab_contents->GetRenderProcessHost()->id()), 158 tab_id_(tab_contents->GetRenderProcessHost()->GetID()),
159 unique_id_(g_save_package_id++), 159 unique_id_(g_save_package_id++),
160 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 160 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
161 DCHECK(page_url_.is_valid()); 161 DCHECK(page_url_.is_valid());
162 InternalInit(); 162 InternalInit();
163 } 163 }
164 164
165 // This is for testing use. Set |finished_| as true because we don't want 165 // This is for testing use. Set |finished_| as true because we don't want
166 // method Cancel to be be called in destructor in test mode. 166 // method Cancel to be be called in destructor in test mode.
167 // We also don't call InternalInit(). 167 // We also don't call InternalInit().
168 SavePackage::SavePackage(TabContents* tab_contents, 168 SavePackage::SavePackage(TabContents* tab_contents,
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 it != saved_success_items_.end(); ++it) 646 it != saved_success_items_.end(); ++it)
647 final_names.push_back(std::make_pair(it->first, 647 final_names.push_back(std::make_pair(it->first,
648 it->second->full_path())); 648 it->second->full_path()));
649 649
650 BrowserThread::PostTask( 650 BrowserThread::PostTask(
651 BrowserThread::FILE, FROM_HERE, 651 BrowserThread::FILE, FROM_HERE,
652 base::Bind(&SaveFileManager::RenameAllFiles, 652 base::Bind(&SaveFileManager::RenameAllFiles,
653 file_manager_, 653 file_manager_,
654 final_names, 654 final_names,
655 dir, 655 dir,
656 tab_contents()->GetRenderProcessHost()->id(), 656 tab_contents()->GetRenderProcessHost()->GetID(),
657 tab_contents()->render_view_host()->routing_id(), 657 tab_contents()->render_view_host()->routing_id(),
658 id())); 658 id()));
659 } 659 }
660 660
661 // Successfully finished all items of this SavePackage. 661 // Successfully finished all items of this SavePackage.
662 void SavePackage::Finish() { 662 void SavePackage::Finish() {
663 // User may cancel the job when we're moving files to the final directory. 663 // User may cancel the job when we're moving files to the final directory.
664 if (canceled()) 664 if (canceled())
665 return; 665 return;
666 666
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 waiting_item_queue_.pop(); 794 waiting_item_queue_.pop();
795 795
796 // Add the item to in_progress_items_. 796 // Add the item to in_progress_items_.
797 SaveUrlItemMap::iterator it = in_progress_items_.find( 797 SaveUrlItemMap::iterator it = in_progress_items_.find(
798 save_item->url().spec()); 798 save_item->url().spec());
799 DCHECK(it == in_progress_items_.end()); 799 DCHECK(it == in_progress_items_.end());
800 in_progress_items_[save_item->url().spec()] = save_item; 800 in_progress_items_[save_item->url().spec()] = save_item;
801 save_item->Start(); 801 save_item->Start();
802 file_manager_->SaveURL(save_item->url(), 802 file_manager_->SaveURL(save_item->url(),
803 save_item->referrer(), 803 save_item->referrer(),
804 tab_contents()->GetRenderProcessHost()->id(), 804 tab_contents()->GetRenderProcessHost()->GetID(),
805 routing_id(), 805 routing_id(),
806 save_item->save_source(), 806 save_item->save_source(),
807 save_item->full_path(), 807 save_item->full_path(),
808 tab_contents()-> 808 tab_contents()->
809 browser_context()->GetResourceContext(), 809 browser_context()->GetResourceContext(),
810 this); 810 this);
811 } while (process_all_remaining_items && waiting_item_queue_.size()); 811 } while (process_all_remaining_items && waiting_item_queue_.size());
812 } 812 }
813 813
814 // Calculate the percentage of whole save page job. 814 // Calculate the percentage of whole save page job.
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 StopObservation(); 1280 StopObservation();
1281 } 1281 }
1282 1282
1283 void SavePackage::FinalizeDownloadEntry() { 1283 void SavePackage::FinalizeDownloadEntry() {
1284 DCHECK(download_); 1284 DCHECK(download_);
1285 DCHECK(download_manager_); 1285 DCHECK(download_manager_);
1286 1286
1287 download_manager_->SavePageDownloadFinished(download_); 1287 download_manager_->SavePageDownloadFinished(download_);
1288 StopObservation(); 1288 StopObservation();
1289 } 1289 }
OLDNEW
« no previous file with comments | « content/browser/download/mhtml_generation_manager.cc ('k') | content/browser/geolocation/geolocation_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698