| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "storage/browser/fileapi/file_system_url_request_job.h" | 5 #include "storage/browser/fileapi/file_system_url_request_job.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 class FileSystemURLRequestJobFactory : public net::URLRequestJobFactory { | 85 class FileSystemURLRequestJobFactory : public net::URLRequestJobFactory { |
| 86 public: | 86 public: |
| 87 FileSystemURLRequestJobFactory(const std::string& storage_domain, | 87 FileSystemURLRequestJobFactory(const std::string& storage_domain, |
| 88 FileSystemContext* context) | 88 FileSystemContext* context) |
| 89 : storage_domain_(storage_domain), file_system_context_(context) { | 89 : storage_domain_(storage_domain), file_system_context_(context) { |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | 92 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 93 const std::string& scheme, | 93 const std::string& scheme, |
| 94 net::URLRequest* request, | 94 net::URLRequest* request, |
| 95 net::NetworkDelegate* network_delegate) const OVERRIDE { | 95 net::NetworkDelegate* network_delegate) const override { |
| 96 return new storage::FileSystemURLRequestJob( | 96 return new storage::FileSystemURLRequestJob( |
| 97 request, network_delegate, storage_domain_, file_system_context_); | 97 request, network_delegate, storage_domain_, file_system_context_); |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE { | 100 virtual bool IsHandledProtocol(const std::string& scheme) const override { |
| 101 return true; | 101 return true; |
| 102 } | 102 } |
| 103 | 103 |
| 104 virtual bool IsHandledURL(const GURL& url) const OVERRIDE { | 104 virtual bool IsHandledURL(const GURL& url) const override { |
| 105 return true; | 105 return true; |
| 106 } | 106 } |
| 107 | 107 |
| 108 virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE { | 108 virtual bool IsSafeRedirectTarget(const GURL& location) const override { |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 std::string storage_domain_; | 113 std::string storage_domain_; |
| 114 FileSystemContext* file_system_context_; | 114 FileSystemContext* file_system_context_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 } // namespace | 117 } // namespace |
| 118 | 118 |
| 119 class FileSystemURLRequestJobTest : public testing::Test { | 119 class FileSystemURLRequestJobTest : public testing::Test { |
| 120 protected: | 120 protected: |
| 121 FileSystemURLRequestJobTest() : weak_factory_(this) { | 121 FileSystemURLRequestJobTest() : weak_factory_(this) { |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual void SetUp() OVERRIDE { | 124 virtual void SetUp() override { |
| 125 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 125 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 126 | 126 |
| 127 // We use the main thread so that we can get the root path synchronously. | 127 // We use the main thread so that we can get the root path synchronously. |
| 128 // TODO(adamk): Run this on the FILE thread we've created as well. | 128 // TODO(adamk): Run this on the FILE thread we've created as well. |
| 129 file_system_context_ = | 129 file_system_context_ = |
| 130 CreateFileSystemContextForTesting(NULL, temp_dir_.path()); | 130 CreateFileSystemContextForTesting(NULL, temp_dir_.path()); |
| 131 | 131 |
| 132 file_system_context_->OpenFileSystem( | 132 file_system_context_->OpenFileSystem( |
| 133 GURL("http://remote/"), | 133 GURL("http://remote/"), |
| 134 storage::kFileSystemTypeTemporary, | 134 storage::kFileSystemTypeTemporary, |
| 135 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 135 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| 136 base::Bind(&FileSystemURLRequestJobTest::OnOpenFileSystem, | 136 base::Bind(&FileSystemURLRequestJobTest::OnOpenFileSystem, |
| 137 weak_factory_.GetWeakPtr())); | 137 weak_factory_.GetWeakPtr())); |
| 138 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 virtual void TearDown() OVERRIDE { | 141 virtual void TearDown() override { |
| 142 // FileReader posts a task to close the file in destructor. | 142 // FileReader posts a task to close the file in destructor. |
| 143 base::RunLoop().RunUntilIdle(); | 143 base::RunLoop().RunUntilIdle(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void SetUpAutoMountContext() { | 146 void SetUpAutoMountContext() { |
| 147 base::FilePath mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); | 147 base::FilePath mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); |
| 148 ASSERT_TRUE(base::CreateDirectory(mnt_point)); | 148 ASSERT_TRUE(base::CreateDirectory(mnt_point)); |
| 149 | 149 |
| 150 ScopedVector<storage::FileSystemBackend> additional_providers; | 150 ScopedVector<storage::FileSystemBackend> additional_providers; |
| 151 additional_providers.push_back(new TestFileSystemBackend( | 151 additional_providers.push_back(new TestFileSystemBackend( |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 EXPECT_TRUE(delegate_->request_failed()); | 459 EXPECT_TRUE(delegate_->request_failed()); |
| 460 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 460 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
| 461 | 461 |
| 462 ASSERT_FALSE( | 462 ASSERT_FALSE( |
| 463 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 463 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
| 464 kValidExternalMountPoint)); | 464 kValidExternalMountPoint)); |
| 465 } | 465 } |
| 466 | 466 |
| 467 } // namespace | 467 } // namespace |
| 468 } // namespace content | 468 } // namespace content |
| OLD | NEW |