| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); | 76 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); |
| 77 ClearUnusedJob(); | 77 ClearUnusedJob(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void OnValidateFileSystem(base::PlatformFileError result) { | 80 void OnValidateFileSystem(base::PlatformFileError result) { |
| 81 ASSERT_EQ(base::PLATFORM_FILE_OK, result); | 81 ASSERT_EQ(base::PLATFORM_FILE_OK, result); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void TestRequestHelper(const GURL& url, bool run_to_completion) { | 84 void TestRequestHelper(const GURL& url, bool run_to_completion) { |
| 85 delegate_.reset(new net::TestDelegate()); | 85 delegate_.reset(new TestDelegate()); |
| 86 delegate_->set_quit_on_redirect(true); | 86 delegate_->set_quit_on_redirect(true); |
| 87 request_.reset(empty_context_.CreateRequest(url, delegate_.get())); | 87 request_.reset(empty_context_.CreateRequest(url, delegate_.get())); |
| 88 job_ = new FileSystemDirURLRequestJob( | 88 job_ = new FileSystemDirURLRequestJob( |
| 89 request_.get(), | 89 request_.get(), |
| 90 empty_context_.network_delegate(), | 90 empty_context_.network_delegate(), |
| 91 file_system_context_.get()); | 91 file_system_context_.get()); |
| 92 | 92 |
| 93 request_->Start(); | 93 request_->Start(); |
| 94 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async | 94 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async |
| 95 if (run_to_completion) | 95 if (run_to_completion) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 kFileSystemTypeTemporary); | 207 kFileSystemTypeTemporary); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Put the message loop at the top, so that it's the last thing deleted. | 210 // Put the message loop at the top, so that it's the last thing deleted. |
| 211 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent | 211 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent |
| 212 // leaks caused by tasks posted during shutdown. | 212 // leaks caused by tasks posted during shutdown. |
| 213 MessageLoop message_loop_; | 213 MessageLoop message_loop_; |
| 214 | 214 |
| 215 ScopedTempDir temp_dir_; | 215 ScopedTempDir temp_dir_; |
| 216 net::URLRequestContext empty_context_; | 216 net::URLRequestContext empty_context_; |
| 217 scoped_ptr<net::TestDelegate> delegate_; | 217 scoped_ptr<TestDelegate> delegate_; |
| 218 scoped_ptr<net::URLRequest> request_; | 218 scoped_ptr<net::URLRequest> request_; |
| 219 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; | 219 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; |
| 220 scoped_refptr<FileSystemContext> file_system_context_; | 220 scoped_refptr<FileSystemContext> file_system_context_; |
| 221 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; | 221 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; |
| 222 | 222 |
| 223 static net::URLRequestJob* job_; | 223 static net::URLRequestJob* job_; |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 // static | 226 // static |
| 227 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL; | 227 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 CreateDirectory("foo"); | 286 CreateDirectory("foo"); |
| 287 TestRequestNoRun(CreateFileSystemURL("foo/")); | 287 TestRequestNoRun(CreateFileSystemURL("foo/")); |
| 288 // Run StartAsync() and only StartAsync(). | 288 // Run StartAsync() and only StartAsync(). |
| 289 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); | 289 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); |
| 290 MessageLoop::current()->RunAllPending(); | 290 MessageLoop::current()->RunAllPending(); |
| 291 // If we get here, success! we didn't crash! | 291 // If we get here, success! we didn't crash! |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace (anonymous) | 294 } // namespace (anonymous) |
| 295 } // namespace fileapi | 295 } // namespace fileapi |
| OLD | NEW |