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

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

Issue 16207005: Fix remaining uses of WeakPtr<T>'s operator T* conversion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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 // This file contains download browser tests that are known to be runnable 5 // This file contains download browser tests that are known to be runnable
6 // in a pure content context. Over time tests should be migrated here. 6 // in a pure content context. Over time tests should be migrated here.
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // retrieval. 113 // retrieval.
114 virtual void RenameAndUniquify( 114 virtual void RenameAndUniquify(
115 const base::FilePath& full_path, 115 const base::FilePath& full_path,
116 const RenameCompletionCallback& callback) OVERRIDE; 116 const RenameCompletionCallback& callback) OVERRIDE;
117 virtual void RenameAndAnnotate( 117 virtual void RenameAndAnnotate(
118 const base::FilePath& full_path, 118 const base::FilePath& full_path,
119 const RenameCompletionCallback& callback) OVERRIDE; 119 const RenameCompletionCallback& callback) OVERRIDE;
120 120
121 private: 121 private:
122 static void RenameCallbackWrapper( 122 static void RenameCallbackWrapper(
123 DownloadFileWithDelayFactory* factory, 123 const base::WeakPtr<DownloadFileWithDelayFactory>& factory,
124 const RenameCompletionCallback& original_callback, 124 const RenameCompletionCallback& original_callback,
125 DownloadInterruptReason reason, 125 DownloadInterruptReason reason,
126 const base::FilePath& path); 126 const base::FilePath& path);
127 127
128 // This variable may only be read on the FILE thread, and may only be 128 // This variable may only be read on the FILE thread, and may only be
129 // indirected through (e.g. methods on DownloadFileWithDelayFactory called) 129 // indirected through (e.g. methods on DownloadFileWithDelayFactory called)
130 // on the UI thread. This is because after construction, 130 // on the UI thread. This is because after construction,
131 // DownloadFileWithDelay lives on the file thread, but 131 // DownloadFileWithDelay lives on the file thread, but
132 // DownloadFileWithDelayFactory is purely a UI thread object. 132 // DownloadFileWithDelayFactory is purely a UI thread object.
133 base::WeakPtr<DownloadFileWithDelayFactory> owner_; 133 base::WeakPtr<DownloadFileWithDelayFactory> owner_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void DownloadFileWithDelay::RenameAndAnnotate( 197 void DownloadFileWithDelay::RenameAndAnnotate(
198 const base::FilePath& full_path, const RenameCompletionCallback& callback) { 198 const base::FilePath& full_path, const RenameCompletionCallback& callback) {
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
200 DownloadFileImpl::RenameAndAnnotate( 200 DownloadFileImpl::RenameAndAnnotate(
201 full_path, base::Bind(DownloadFileWithDelay::RenameCallbackWrapper, 201 full_path, base::Bind(DownloadFileWithDelay::RenameCallbackWrapper,
202 owner_, callback)); 202 owner_, callback));
203 } 203 }
204 204
205 // static 205 // static
206 void DownloadFileWithDelay::RenameCallbackWrapper( 206 void DownloadFileWithDelay::RenameCallbackWrapper(
207 DownloadFileWithDelayFactory* factory, 207 const base::WeakPtr<DownloadFileWithDelayFactory>& factory,
208 const RenameCompletionCallback& original_callback, 208 const RenameCompletionCallback& original_callback,
209 DownloadInterruptReason reason, 209 DownloadInterruptReason reason,
210 const base::FilePath& path) { 210 const base::FilePath& path) {
211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
212 if (!factory.get())
213 return;
212 factory->AddRenameCallback(base::Bind(original_callback, reason, path)); 214 factory->AddRenameCallback(base::Bind(original_callback, reason, path));
213 } 215 }
214 216
215 DownloadFileWithDelayFactory::DownloadFileWithDelayFactory() 217 DownloadFileWithDelayFactory::DownloadFileWithDelayFactory()
216 : weak_ptr_factory_(this), 218 : weak_ptr_factory_(this),
217 waiting_(false) {} 219 waiting_(false) {}
218 DownloadFileWithDelayFactory::~DownloadFileWithDelayFactory() {} 220 DownloadFileWithDelayFactory::~DownloadFileWithDelayFactory() {}
219 221
220 DownloadFile* DownloadFileWithDelayFactory::CreateFile( 222 DownloadFile* DownloadFileWithDelayFactory::CreateFile(
221 scoped_ptr<DownloadSaveInfo> save_info, 223 scoped_ptr<DownloadSaveInfo> save_info,
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 // Start the second download and wait until it's done. The test server is 1555 // Start the second download and wait until it's done. The test server is
1554 // single threaded. The response to this download request should follow the 1556 // single threaded. The response to this download request should follow the
1555 // response to the previous resumption request. 1557 // response to the previous resumption request.
1556 GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); 1558 GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x"));
1557 DownloadAndWait(shell(), url2, DownloadItem::COMPLETE); 1559 DownloadAndWait(shell(), url2, DownloadItem::COMPLETE);
1558 1560
1559 EXPECT_TRUE(EnsureNoPendingDownloads()); 1561 EXPECT_TRUE(EnsureNoPendingDownloads());
1560 } 1562 }
1561 1563
1562 } // namespace content 1564 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc ('k') | gpu/command_buffer/service/context_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698