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" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
13 #include "base/location.h" | |
14 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/thread_task_runner_handle.h" | |
20 #include "content/public/test/mock_special_storage_policy.h" | 19 #include "content/public/test/mock_special_storage_policy.h" |
21 #include "content/public/test/test_file_system_backend.h" | 20 #include "content/public/test/test_file_system_backend.h" |
22 #include "content/public/test/test_file_system_context.h" | 21 #include "content/public/test/test_file_system_context.h" |
23 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
24 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
25 #include "net/base/request_priority.h" | 24 #include "net/base/request_priority.h" |
26 #include "net/http/http_request_headers.h" | 25 #include "net/http/http_request_headers.h" |
27 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
28 #include "net/url_request/url_request_context.h" | 27 #include "net/url_request/url_request_context.h" |
29 #include "net/url_request/url_request_test_util.h" | 28 #include "net/url_request/url_request_test_util.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 request_.reset(NULL); | 146 request_.reset(NULL); |
148 delegate_.reset(NULL); | 147 delegate_.reset(NULL); |
149 } | 148 } |
150 | 149 |
151 void SetUpAutoMountContext(base::FilePath* mnt_point) { | 150 void SetUpAutoMountContext(base::FilePath* mnt_point) { |
152 *mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); | 151 *mnt_point = temp_dir_.path().AppendASCII("auto_mount_dir"); |
153 ASSERT_TRUE(base::CreateDirectory(*mnt_point)); | 152 ASSERT_TRUE(base::CreateDirectory(*mnt_point)); |
154 | 153 |
155 ScopedVector<storage::FileSystemBackend> additional_providers; | 154 ScopedVector<storage::FileSystemBackend> additional_providers; |
156 additional_providers.push_back(new TestFileSystemBackend( | 155 additional_providers.push_back(new TestFileSystemBackend( |
157 base::ThreadTaskRunnerHandle::Get().get(), *mnt_point)); | 156 base::MessageLoopProxy::current().get(), *mnt_point)); |
158 | 157 |
159 std::vector<storage::URLRequestAutoMountHandler> handlers; | 158 std::vector<storage::URLRequestAutoMountHandler> handlers; |
160 handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); | 159 handlers.push_back(base::Bind(&TestAutoMountForURLRequest)); |
161 | 160 |
162 file_system_context_ = CreateFileSystemContextWithAutoMountersForTesting( | 161 file_system_context_ = CreateFileSystemContextWithAutoMountersForTesting( |
163 NULL, additional_providers.Pass(), handlers, temp_dir_.path()); | 162 NULL, additional_providers.Pass(), handlers, temp_dir_.path()); |
164 } | 163 } |
165 | 164 |
166 void OnOpenFileSystem(const GURL& root_url, | 165 void OnOpenFileSystem(const GURL& root_url, |
167 const std::string& name, | 166 const std::string& name, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 278 |
280 GURL CreateFileSystemURL(const std::string path) { | 279 GURL CreateFileSystemURL(const std::string path) { |
281 return GURL(kFileSystemURLPrefix + path); | 280 return GURL(kFileSystemURLPrefix + path); |
282 } | 281 } |
283 | 282 |
284 storage::FileSystemFileUtil* file_util() { | 283 storage::FileSystemFileUtil* file_util() { |
285 return file_system_context_->sandbox_delegate()->sync_file_util(); | 284 return file_system_context_->sandbox_delegate()->sync_file_util(); |
286 } | 285 } |
287 | 286 |
288 // Put the message loop at the top, so that it's the last thing deleted. | 287 // Put the message loop at the top, so that it's the last thing deleted. |
289 // Delete all task runner objects before the MessageLoop, to help prevent | 288 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent |
290 // leaks caused by tasks posted during shutdown. | 289 // leaks caused by tasks posted during shutdown. |
291 base::MessageLoopForIO message_loop_; | 290 base::MessageLoopForIO message_loop_; |
292 | 291 |
293 base::ScopedTempDir temp_dir_; | 292 base::ScopedTempDir temp_dir_; |
294 net::URLRequestContext empty_context_; | 293 net::URLRequestContext empty_context_; |
295 scoped_ptr<net::TestDelegate> delegate_; | 294 scoped_ptr<net::TestDelegate> delegate_; |
296 scoped_ptr<net::URLRequest> request_; | 295 scoped_ptr<net::URLRequest> request_; |
297 scoped_ptr<FileSystemDirURLRequestJobFactory> job_factory_; | 296 scoped_ptr<FileSystemDirURLRequestJobFactory> job_factory_; |
298 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy_; | 297 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy_; |
299 scoped_refptr<FileSystemContext> file_system_context_; | 298 scoped_refptr<FileSystemContext> file_system_context_; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 ASSERT_FALSE(request_->status().is_success()); | 445 ASSERT_FALSE(request_->status().is_success()); |
447 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 446 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
448 | 447 |
449 ASSERT_FALSE( | 448 ASSERT_FALSE( |
450 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 449 storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
451 kValidExternalMountPoint)); | 450 kValidExternalMountPoint)); |
452 } | 451 } |
453 | 452 |
454 } // namespace | 453 } // namespace |
455 } // namespace content | 454 } // namespace content |
OLD | NEW |