| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 Loading... |
| 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 new MockFileSystemOptions()); | 67 new MockFileSystemOptions()); |
| 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 Loading... |
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask); | 289 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask); |
| 293 MessageLoop::current()->Run(); | 290 MessageLoop::current()->Run(); |
| 294 | 291 |
| 295 request_.reset(); | 292 request_.reset(); |
| 296 MessageLoop::current()->RunAllPending(); | 293 MessageLoop::current()->RunAllPending(); |
| 297 // If we get here, success! we didn't crash! | 294 // If we get here, success! we didn't crash! |
| 298 } | 295 } |
| 299 | 296 |
| 300 } // namespace (anonymous) | 297 } // namespace (anonymous) |
| 301 } // namespace fileapi | 298 } // namespace fileapi |
| OLD | NEW |