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

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

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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
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 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) 5 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit)
6 // rather than as part of test_shell_tests because they rely on being able 6 // rather than as part of test_shell_tests because they rely on being able
7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses
8 // TYPE_UI, which URLRequest doesn't allow. 8 // TYPE_UI, which URLRequest doesn't allow.
9 // 9 //
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 special_storage_policy_ = new quota::MockSpecialStoragePolicy; 60 special_storage_policy_ = new quota::MockSpecialStoragePolicy;
61 file_system_context_ = 61 file_system_context_ =
62 new FileSystemContext( 62 new FileSystemContext(
63 file_thread_proxy_, 63 file_thread_proxy_,
64 base::MessageLoopProxy::current(), 64 base::MessageLoopProxy::current(),
65 special_storage_policy_, NULL, 65 special_storage_policy_, NULL,
66 temp_dir_.path(), 66 temp_dir_.path(),
67 CreateAllowFileAccessOptions()); 67 CreateAllowFileAccessOptions());
68 68
69 file_system_context_->sandbox_provider()->ValidateFileSystemRootAndGetURL( 69 file_system_context_->sandbox_provider()->ValidateFileSystemRoot(
70 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create 70 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
71 base::Bind(&FileSystemDirURLRequestJobTest::OnGetRootPath, 71 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem,
72 weak_factory_.GetWeakPtr())); 72 weak_factory_.GetWeakPtr()));
73 MessageLoop::current()->RunAllPending(); 73 MessageLoop::current()->RunAllPending();
74 74
75 net::URLRequest::Deprecated::RegisterProtocolFactory( 75 net::URLRequest::Deprecated::RegisterProtocolFactory(
76 "filesystem", &FileSystemDirURLRequestJobFactory); 76 "filesystem", &FileSystemDirURLRequestJobFactory);
77 } 77 }
78 78
79 virtual void TearDown() OVERRIDE { 79 virtual void TearDown() OVERRIDE {
80 // NOTE: order matters, request must die before delegate 80 // NOTE: order matters, request must die before delegate
81 request_.reset(NULL); 81 request_.reset(NULL);
82 delegate_.reset(NULL); 82 delegate_.reset(NULL);
83 83
84 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); 84 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL);
85 } 85 }
86 86
87 void OnGetRootPath(bool success, const FilePath& root_path, 87 void OnValidateFileSystem(base::PlatformFileError result) {
88 const std::string& name) { 88 ASSERT_EQ(base::PLATFORM_FILE_OK, result);
89 ASSERT_TRUE(success);
90 root_path_ = root_path;
91 } 89 }
92 90
93 void TestRequestHelper(const GURL& url, bool run_to_completion) { 91 void TestRequestHelper(const GURL& url, bool run_to_completion) {
94 delegate_.reset(new TestDelegate()); 92 delegate_.reset(new TestDelegate());
95 delegate_->set_quit_on_redirect(true); 93 delegate_->set_quit_on_redirect(true);
96 request_.reset(new net::URLRequest(url, delegate_.get())); 94 request_.reset(new net::URLRequest(url, delegate_.get()));
97 job_ = new FileSystemDirURLRequestJob(request_.get(), 95 job_ = new FileSystemDirURLRequestJob(request_.get(),
98 file_system_context_.get(), 96 file_system_context_.get(),
99 file_thread_proxy_); 97 file_thread_proxy_);
100 98
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return file_system_context_->sandbox_provider()->GetFileUtil(); 200 return file_system_context_->sandbox_provider()->GetFileUtil();
203 } 201 }
204 202
205 // Put the message loop at the top, so that it's the last thing deleted. 203 // Put the message loop at the top, so that it's the last thing deleted.
206 MessageLoop message_loop_; 204 MessageLoop message_loop_;
207 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent 205 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent
208 // leaks caused by tasks posted during shutdown. 206 // leaks caused by tasks posted during shutdown.
209 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; 207 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
210 208
211 ScopedTempDir temp_dir_; 209 ScopedTempDir temp_dir_;
212 FilePath root_path_;
213 scoped_ptr<net::URLRequest> request_; 210 scoped_ptr<net::URLRequest> request_;
214 scoped_ptr<TestDelegate> delegate_; 211 scoped_ptr<TestDelegate> delegate_;
215 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; 212 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
216 scoped_refptr<FileSystemContext> file_system_context_; 213 scoped_refptr<FileSystemContext> file_system_context_;
217 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; 214 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_;
218 215
219 static net::URLRequestJob* job_; 216 static net::URLRequestJob* job_;
220 }; 217 };
221 218
222 // static 219 // static
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 CreateDirectory("foo"); 279 CreateDirectory("foo");
283 TestRequestNoRun(CreateFileSystemURL("foo/")); 280 TestRequestNoRun(CreateFileSystemURL("foo/"));
284 // Run StartAsync() and only StartAsync(). 281 // Run StartAsync() and only StartAsync().
285 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); 282 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release());
286 MessageLoop::current()->RunAllPending(); 283 MessageLoop::current()->RunAllPending();
287 // If we get here, success! we didn't crash! 284 // If we get here, success! we didn't crash!
288 } 285 }
289 286
290 } // namespace (anonymous) 287 } // namespace (anonymous)
291 } // namespace fileapi 288 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_dir_url_request_job.cc ('k') | webkit/fileapi/file_system_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698