| 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_dir_url_request_job.h" | 5 #include "storage/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/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 class FileSystemDirURLRequestJobFactory : public net::URLRequestJobFactory { | 76 class FileSystemDirURLRequestJobFactory : public net::URLRequestJobFactory { |
| 77 public: | 77 public: |
| 78 FileSystemDirURLRequestJobFactory(const std::string& storage_domain, | 78 FileSystemDirURLRequestJobFactory(const std::string& storage_domain, |
| 79 FileSystemContext* context) | 79 FileSystemContext* context) |
| 80 : storage_domain_(storage_domain), file_system_context_(context) { | 80 : storage_domain_(storage_domain), file_system_context_(context) { |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | 83 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 84 const std::string& scheme, | 84 const std::string& scheme, |
| 85 net::URLRequest* request, | 85 net::URLRequest* request, |
| 86 net::NetworkDelegate* network_delegate) const OVERRIDE { | 86 net::NetworkDelegate* network_delegate) const override { |
| 87 return new storage::FileSystemDirURLRequestJob( | 87 return new storage::FileSystemDirURLRequestJob( |
| 88 request, network_delegate, storage_domain_, file_system_context_); | 88 request, network_delegate, storage_domain_, file_system_context_); |
| 89 } | 89 } |
| 90 | 90 |
| 91 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE { | 91 virtual bool IsHandledProtocol(const std::string& scheme) const override { |
| 92 return true; | 92 return true; |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual bool IsHandledURL(const GURL& url) const OVERRIDE { | 95 virtual bool IsHandledURL(const GURL& url) const override { |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE { | 99 virtual bool IsSafeRedirectTarget(const GURL& location) const override { |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 std::string storage_domain_; | 104 std::string storage_domain_; |
| 105 FileSystemContext* file_system_context_; | 105 FileSystemContext* file_system_context_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 | 108 |
| 109 } // namespace | 109 } // namespace |
| 110 | 110 |
| 111 class FileSystemDirURLRequestJobTest : public testing::Test { | 111 class FileSystemDirURLRequestJobTest : public testing::Test { |
| 112 protected: | 112 protected: |
| 113 FileSystemDirURLRequestJobTest() | 113 FileSystemDirURLRequestJobTest() |
| 114 : weak_factory_(this) { | 114 : weak_factory_(this) { |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual void SetUp() OVERRIDE { | 117 virtual void SetUp() override { |
| 118 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 118 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 119 | 119 |
| 120 special_storage_policy_ = new MockSpecialStoragePolicy; | 120 special_storage_policy_ = new MockSpecialStoragePolicy; |
| 121 file_system_context_ = CreateFileSystemContextForTesting( | 121 file_system_context_ = CreateFileSystemContextForTesting( |
| 122 NULL, temp_dir_.path()); | 122 NULL, temp_dir_.path()); |
| 123 | 123 |
| 124 file_system_context_->OpenFileSystem( | 124 file_system_context_->OpenFileSystem( |
| 125 GURL("http://remote/"), | 125 GURL("http://remote/"), |
| 126 storage::kFileSystemTypeTemporary, | 126 storage::kFileSystemTypeTemporary, |
| 127 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 127 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| 128 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, | 128 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, |
| 129 weak_factory_.GetWeakPtr())); | 129 weak_factory_.GetWeakPtr())); |
| 130 base::RunLoop().RunUntilIdle(); | 130 base::RunLoop().RunUntilIdle(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 virtual void TearDown() OVERRIDE { | 133 virtual void TearDown() override { |
| 134 // NOTE: order matters, request must die before delegate | 134 // NOTE: order matters, request must die before delegate |
| 135 request_.reset(NULL); | 135 request_.reset(NULL); |
| 136 delegate_.reset(NULL); | 136 delegate_.reset(NULL); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void SetUpAutoMountContext(base::FilePath* mnt_point) { | 139 void SetUpAutoMountContext(base::FilePath* mnt_point) { |
| 140 *mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); | 140 *mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); |
| 141 ASSERT_TRUE(base::CreateDirectory(*mnt_point)); | 141 ASSERT_TRUE(base::CreateDirectory(*mnt_point)); |
| 142 | 142 |
| 143 ScopedVector<storage::FileSystemBackend> additional_providers; | 143 ScopedVector<storage::FileSystemBackend> additional_providers; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 ASSERT_FALSE(request_->status().is_success()); | 434 ASSERT_FALSE(request_->status().is_success()); |
| 435 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 435 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
| 436 | 436 |
| 437 ASSERT_FALSE( | 437 ASSERT_FALSE( |
| 438 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 438 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
| 439 kValidExternalMountPoint)); | 439 kValidExternalMountPoint)); |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace (anonymous) | 442 } // namespace (anonymous) |
| 443 } // namespace content | 443 } // namespace content |
| OLD | NEW |