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

Side by Side Diff: webkit/fileapi/file_system_dir_url_request_job_unittest.cc

Issue 10559036: Added URLRequestContext to constructor for URLRequest. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated unittests Created 8 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
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 "webkit/fileapi/file_system_dir_url_request_job.h" 5 #include "webkit/fileapi/file_system_dir_url_request_job.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ClearUnusedJob(); 78 ClearUnusedJob();
79 } 79 }
80 80
81 void OnValidateFileSystem(base::PlatformFileError result) { 81 void OnValidateFileSystem(base::PlatformFileError result) {
82 ASSERT_EQ(base::PLATFORM_FILE_OK, result); 82 ASSERT_EQ(base::PLATFORM_FILE_OK, result);
83 } 83 }
84 84
85 void TestRequestHelper(const GURL& url, bool run_to_completion) { 85 void TestRequestHelper(const GURL& url, bool run_to_completion) {
86 delegate_.reset(new TestDelegate()); 86 delegate_.reset(new TestDelegate());
87 delegate_->set_quit_on_redirect(true); 87 delegate_->set_quit_on_redirect(true);
88 request_.reset(new net::URLRequest(url, delegate_.get())); 88 request_.reset(new net::URLRequest(url,
89 delegate_.get(),
90 &empty_context_));
89 job_ = new FileSystemDirURLRequestJob(request_.get(), 91 job_ = new FileSystemDirURLRequestJob(request_.get(),
90 file_system_context_.get()); 92 file_system_context_.get());
91 93
92 request_->Start(); 94 request_->Start();
93 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async 95 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async
94 if (run_to_completion) 96 if (run_to_completion)
95 MessageLoop::current()->Run(); 97 MessageLoop::current()->Run();
96 } 98 }
97 99
98 void TestRequest(const GURL& url) { 100 void TestRequest(const GURL& url) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return file_system_context_->sandbox_provider()->GetFileUtil(); 206 return file_system_context_->sandbox_provider()->GetFileUtil();
205 } 207 }
206 208
207 // Put the message loop at the top, so that it's the last thing deleted. 209 // Put the message loop at the top, so that it's the last thing deleted.
208 MessageLoop message_loop_; 210 MessageLoop message_loop_;
209 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent 211 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent
210 // leaks caused by tasks posted during shutdown. 212 // leaks caused by tasks posted during shutdown.
211 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; 213 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
212 214
213 ScopedTempDir temp_dir_; 215 ScopedTempDir temp_dir_;
216 net::URLRequestContext empty_context_;
214 scoped_ptr<net::URLRequest> request_; 217 scoped_ptr<net::URLRequest> request_;
erikwright (departed) 2012/06/19 21:06:22 Is it bad that delegate_ is below request_?
shalev 2012/06/20 20:13:12 Done.
215 scoped_ptr<TestDelegate> delegate_; 218 scoped_ptr<TestDelegate> delegate_;
216 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; 219 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
217 scoped_refptr<FileSystemContext> file_system_context_; 220 scoped_refptr<FileSystemContext> file_system_context_;
218 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; 221 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_;
219 222
220 static net::URLRequestJob* job_; 223 static net::URLRequestJob* job_;
221 }; 224 };
222 225
223 // static 226 // static
224 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL; 227 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 CreateDirectory("foo"); 286 CreateDirectory("foo");
284 TestRequestNoRun(CreateFileSystemURL("foo/")); 287 TestRequestNoRun(CreateFileSystemURL("foo/"));
285 // Run StartAsync() and only StartAsync(). 288 // Run StartAsync() and only StartAsync().
286 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); 289 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release());
287 MessageLoop::current()->RunAllPending(); 290 MessageLoop::current()->RunAllPending();
288 // If we get here, success! we didn't crash! 291 // If we get here, success! we didn't crash!
289 } 292 }
290 293
291 } // namespace (anonymous) 294 } // namespace (anonymous)
292 } // namespace fileapi 295 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698