| 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/browser/fileapi/file_system_dir_url_request_job.h" | 5 #include "webkit/browser/fileapi/file_system_dir_url_request_job.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 weak_factory_(this) { | 46 weak_factory_(this) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() OVERRIDE { |
| 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 51 | 51 |
| 52 special_storage_policy_ = new quota::MockSpecialStoragePolicy; | 52 special_storage_policy_ = new quota::MockSpecialStoragePolicy; |
| 53 file_system_context_ = CreateFileSystemContextForTesting( | 53 file_system_context_ = CreateFileSystemContextForTesting( |
| 54 NULL, temp_dir_.path()); | 54 NULL, temp_dir_.path()); |
| 55 | 55 |
| 56 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( | 56 file_system_context_->sandbox_provider()->OpenFileSystem( |
| 57 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create | 57 GURL("http://remote/"), kFileSystemTypeTemporary, |
| 58 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem, | 58 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| 59 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, |
| 59 weak_factory_.GetWeakPtr())); | 60 weak_factory_.GetWeakPtr())); |
| 60 base::MessageLoop::current()->RunUntilIdle(); | 61 base::MessageLoop::current()->RunUntilIdle(); |
| 61 | 62 |
| 62 net::URLRequest::Deprecated::RegisterProtocolFactory( | 63 net::URLRequest::Deprecated::RegisterProtocolFactory( |
| 63 "filesystem", &FileSystemDirURLRequestJobFactory); | 64 "filesystem", &FileSystemDirURLRequestJobFactory); |
| 64 } | 65 } |
| 65 | 66 |
| 66 virtual void TearDown() OVERRIDE { | 67 virtual void TearDown() OVERRIDE { |
| 67 // NOTE: order matters, request must die before delegate | 68 // NOTE: order matters, request must die before delegate |
| 68 request_.reset(NULL); | 69 request_.reset(NULL); |
| 69 delegate_.reset(NULL); | 70 delegate_.reset(NULL); |
| 70 | 71 |
| 71 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); | 72 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); |
| 72 ClearUnusedJob(); | 73 ClearUnusedJob(); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void OnValidateFileSystem(base::PlatformFileError result) { | 76 void OnOpenFileSystem(base::PlatformFileError result) { |
| 76 ASSERT_EQ(base::PLATFORM_FILE_OK, result); | 77 ASSERT_EQ(base::PLATFORM_FILE_OK, result); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void TestRequestHelper(const GURL& url, bool run_to_completion) { | 80 void TestRequestHelper(const GURL& url, bool run_to_completion) { |
| 80 delegate_.reset(new net::TestDelegate()); | 81 delegate_.reset(new net::TestDelegate()); |
| 81 delegate_->set_quit_on_redirect(true); | 82 delegate_->set_quit_on_redirect(true); |
| 82 request_.reset(empty_context_.CreateRequest(url, delegate_.get())); | 83 request_.reset(empty_context_.CreateRequest(url, delegate_.get())); |
| 83 job_ = new FileSystemDirURLRequestJob( | 84 job_ = new FileSystemDirURLRequestJob( |
| 84 request_.get(), NULL, file_system_context_.get()); | 85 request_.get(), NULL, file_system_context_.get()); |
| 85 | 86 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 CreateDirectory("foo"); | 281 CreateDirectory("foo"); |
| 281 TestRequestNoRun(CreateFileSystemURL("foo/")); | 282 TestRequestNoRun(CreateFileSystemURL("foo/")); |
| 282 // Run StartAsync() and only StartAsync(). | 283 // Run StartAsync() and only StartAsync(). |
| 283 base::MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); | 284 base::MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); |
| 284 base::MessageLoop::current()->RunUntilIdle(); | 285 base::MessageLoop::current()->RunUntilIdle(); |
| 285 // If we get here, success! we didn't crash! | 286 // If we get here, success! we didn't crash! |
| 286 } | 287 } |
| 287 | 288 |
| 288 } // namespace (anonymous) | 289 } // namespace (anonymous) |
| 289 } // namespace fileapi | 290 } // namespace fileapi |
| OLD | NEW |