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

Side by Side Diff: content/public/test/test_file_error_injector.cc

Issue 17315009: [Downloads] Add more browsertests for resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Serialize alls to TestFileErrorInjector accounting methods. Created 7 years, 5 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/download_browsertest.cc ('k') | no next file » | 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) 2012 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/public/test/test_file_error_injector.h" 5 #include "content/public/test/test_file_error_injector.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const TestFileErrorInjector::FileErrorInfo& error_info, 116 const TestFileErrorInjector::FileErrorInfo& error_info,
117 const ConstructionCallback& ctor_callback, 117 const ConstructionCallback& ctor_callback,
118 const DestructionCallback& dtor_callback) 118 const DestructionCallback& dtor_callback)
119 : DownloadFileImpl( 119 : DownloadFileImpl(
120 save_info.Pass(), default_download_directory, url, referrer_url, 120 save_info.Pass(), default_download_directory, url, referrer_url,
121 calculate_hash, stream.Pass(), bound_net_log, 121 calculate_hash, stream.Pass(), bound_net_log,
122 power_save_blocker.Pass(), observer), 122 power_save_blocker.Pass(), observer),
123 source_url_(url), 123 source_url_(url),
124 error_info_(error_info), 124 error_info_(error_info),
125 destruction_callback_(dtor_callback) { 125 destruction_callback_(dtor_callback) {
126 ctor_callback.Run(source_url_); 126 // DownloadFiles are created on the UI thread and are destroyed on the FILE
127 // thread. Schedule the ConstructionCallback on the FILE thread so that if a
128 // DownloadItem schedules a DownloadFile to be destroyed and creates another
129 // one (as happens during download resumption), then the DestructionCallback
130 // for the old DownloadFile is run before the ConstructionCallback for the
131 // next DownloadFile.
132 BrowserThread::PostTask(
133 BrowserThread::FILE,
134 FROM_HERE,
135 base::Bind(ctor_callback, source_url_));
127 } 136 }
128 137
129 DownloadFileWithErrors::~DownloadFileWithErrors() { 138 DownloadFileWithErrors::~DownloadFileWithErrors() {
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
130 destruction_callback_.Run(source_url_); 140 destruction_callback_.Run(source_url_);
131 } 141 }
132 142
133 void DownloadFileWithErrors::Initialize( 143 void DownloadFileWithErrors::Initialize(
134 const InitializeCallback& callback) { 144 const InitializeCallback& callback) {
135 DownloadInterruptReason error_to_return = DOWNLOAD_INTERRUPT_REASON_NONE; 145 DownloadInterruptReason error_to_return = DOWNLOAD_INTERRUPT_REASON_NONE;
136 InitializeCallback callback_to_use = callback; 146 InitializeCallback callback_to_use = callback;
137 147
138 // Replace callback if the error needs to be overwritten. 148 // Replace callback if the error needs to be overwritten.
139 if (OverwriteError( 149 if (OverwriteError(
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 case FILE_OPERATION_RENAME_ANNOTATE: 478 case FILE_OPERATION_RENAME_ANNOTATE:
469 return "RENAME_ANNOTATE"; 479 return "RENAME_ANNOTATE";
470 default: 480 default:
471 break; 481 break;
472 } 482 }
473 483
474 return "Unknown"; 484 return "Unknown";
475 } 485 }
476 486
477 } // namespace content 487 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698