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

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

Issue 9071001: base::Bind: Remove ScopedRunnableMethodFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 8 years, 11 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 | « content/browser/download/save_package.h ('k') | content/renderer/render_thread_impl.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 saved_main_directory_path_(directory_full_path), 127 saved_main_directory_path_(directory_full_path),
128 title_(tab_contents->GetTitle()), 128 title_(tab_contents->GetTitle()),
129 start_tick_(base::TimeTicks::Now()), 129 start_tick_(base::TimeTicks::Now()),
130 finished_(false), 130 finished_(false),
131 user_canceled_(false), 131 user_canceled_(false),
132 disk_error_occurred_(false), 132 disk_error_occurred_(false),
133 save_type_(save_type), 133 save_type_(save_type),
134 all_save_items_count_(0), 134 all_save_items_count_(0),
135 wait_state_(INITIALIZE), 135 wait_state_(INITIALIZE),
136 tab_id_(tab_contents->GetRenderProcessHost()->GetID()), 136 tab_id_(tab_contents->GetRenderProcessHost()->GetID()),
137 unique_id_(g_save_package_id++), 137 unique_id_(g_save_package_id++) {
138 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
139 DCHECK(page_url_.is_valid()); 138 DCHECK(page_url_.is_valid());
140 DCHECK(save_type_ == SAVE_AS_ONLY_HTML || 139 DCHECK(save_type_ == SAVE_AS_ONLY_HTML ||
141 save_type_ == SAVE_AS_COMPLETE_HTML); 140 save_type_ == SAVE_AS_COMPLETE_HTML);
142 DCHECK(!saved_main_file_path_.empty() && 141 DCHECK(!saved_main_file_path_.empty() &&
143 saved_main_file_path_.value().length() <= kMaxFilePathLength); 142 saved_main_file_path_.value().length() <= kMaxFilePathLength);
144 DCHECK(!saved_main_directory_path_.empty() && 143 DCHECK(!saved_main_directory_path_.empty() &&
145 saved_main_directory_path_.value().length() < kMaxFilePathLength); 144 saved_main_directory_path_.value().length() < kMaxFilePathLength);
146 InternalInit(); 145 InternalInit();
147 } 146 }
148 147
149 SavePackage::SavePackage(TabContents* tab_contents) 148 SavePackage::SavePackage(TabContents* tab_contents)
150 : content::WebContentsObserver(tab_contents), 149 : content::WebContentsObserver(tab_contents),
151 file_manager_(NULL), 150 file_manager_(NULL),
152 download_manager_(NULL), 151 download_manager_(NULL),
153 download_(NULL), 152 download_(NULL),
154 page_url_(GetUrlToBeSaved()), 153 page_url_(GetUrlToBeSaved()),
155 title_(tab_contents->GetTitle()), 154 title_(tab_contents->GetTitle()),
156 start_tick_(base::TimeTicks::Now()), 155 start_tick_(base::TimeTicks::Now()),
157 finished_(false), 156 finished_(false),
158 user_canceled_(false), 157 user_canceled_(false),
159 disk_error_occurred_(false), 158 disk_error_occurred_(false),
160 save_type_(SAVE_TYPE_UNKNOWN), 159 save_type_(SAVE_TYPE_UNKNOWN),
161 all_save_items_count_(0), 160 all_save_items_count_(0),
162 wait_state_(INITIALIZE), 161 wait_state_(INITIALIZE),
163 tab_id_(tab_contents->GetRenderProcessHost()->GetID()), 162 tab_id_(tab_contents->GetRenderProcessHost()->GetID()),
164 unique_id_(g_save_package_id++), 163 unique_id_(g_save_package_id++) {
165 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
166 DCHECK(page_url_.is_valid()); 164 DCHECK(page_url_.is_valid());
167 InternalInit(); 165 InternalInit();
168 } 166 }
169 167
170 // This is for testing use. Set |finished_| as true because we don't want 168 // This is for testing use. Set |finished_| as true because we don't want
171 // method Cancel to be be called in destructor in test mode. 169 // method Cancel to be be called in destructor in test mode.
172 // We also don't call InternalInit(). 170 // We also don't call InternalInit().
173 SavePackage::SavePackage(TabContents* tab_contents, 171 SavePackage::SavePackage(TabContents* tab_contents,
174 const FilePath& file_full_path, 172 const FilePath& file_full_path,
175 const FilePath& directory_full_path) 173 const FilePath& directory_full_path)
176 : content::WebContentsObserver(tab_contents), 174 : content::WebContentsObserver(tab_contents),
177 file_manager_(NULL), 175 file_manager_(NULL),
178 download_manager_(NULL), 176 download_manager_(NULL),
179 download_(NULL), 177 download_(NULL),
180 saved_main_file_path_(file_full_path), 178 saved_main_file_path_(file_full_path),
181 saved_main_directory_path_(directory_full_path), 179 saved_main_directory_path_(directory_full_path),
182 start_tick_(base::TimeTicks::Now()), 180 start_tick_(base::TimeTicks::Now()),
183 finished_(true), 181 finished_(true),
184 user_canceled_(false), 182 user_canceled_(false),
185 disk_error_occurred_(false), 183 disk_error_occurred_(false),
186 save_type_(SAVE_TYPE_UNKNOWN), 184 save_type_(SAVE_TYPE_UNKNOWN),
187 all_save_items_count_(0), 185 all_save_items_count_(0),
188 wait_state_(INITIALIZE), 186 wait_state_(INITIALIZE),
189 tab_id_(0), 187 tab_id_(0),
190 unique_id_(g_save_package_id++), 188 unique_id_(g_save_package_id++) {
191 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
192 } 189 }
193 190
194 SavePackage::~SavePackage() { 191 SavePackage::~SavePackage() {
195 // Stop receiving saving job's updates 192 // Stop receiving saving job's updates
196 if (!finished_ && !canceled()) { 193 if (!finished_ && !canceled()) {
197 // Unexpected quit. 194 // Unexpected quit.
198 Cancel(true); 195 Cancel(true);
199 } 196 }
200 197
201 // We should no longer be observing the DownloadItem at this point. 198 // We should no longer be observing the DownloadItem at this point.
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 StopObservation(); 1292 StopObservation();
1296 } 1293 }
1297 1294
1298 void SavePackage::FinalizeDownloadEntry() { 1295 void SavePackage::FinalizeDownloadEntry() {
1299 DCHECK(download_); 1296 DCHECK(download_);
1300 DCHECK(download_manager_); 1297 DCHECK(download_manager_);
1301 1298
1302 download_manager_->SavePageDownloadFinished(download_); 1299 download_manager_->SavePageDownloadFinished(download_);
1303 StopObservation(); 1300 StopObservation();
1304 } 1301 }
OLDNEW
« no previous file with comments | « content/browser/download/save_package.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698