| 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 "webkit/browser/fileapi/file_system_url_request_job.h" | 5 #include "webkit/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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (pending_job_.get()) { | 85 if (pending_job_.get()) { |
| 86 pending_job_->Kill(); | 86 pending_job_->Kill(); |
| 87 pending_job_ = NULL; | 87 pending_job_ = NULL; |
| 88 } | 88 } |
| 89 // FileReader posts a task to close the file in destructor. | 89 // FileReader posts a task to close the file in destructor. |
| 90 base::RunLoop().RunUntilIdle(); | 90 base::RunLoop().RunUntilIdle(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void OnOpenFileSystem(const GURL& root_url, | 93 void OnOpenFileSystem(const GURL& root_url, |
| 94 const std::string& name, | 94 const std::string& name, |
| 95 base::PlatformFileError result) { | 95 base::File::Error result) { |
| 96 ASSERT_EQ(base::PLATFORM_FILE_OK, result); | 96 ASSERT_EQ(base::File::FILE_OK, result); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void TestRequestHelper(const GURL& url, | 99 void TestRequestHelper(const GURL& url, |
| 100 const net::HttpRequestHeaders* headers, | 100 const net::HttpRequestHeaders* headers, |
| 101 bool run_to_completion, | 101 bool run_to_completion, |
| 102 FileSystemContext* file_system_context) { | 102 FileSystemContext* file_system_context) { |
| 103 delegate_.reset(new net::TestDelegate()); | 103 delegate_.reset(new net::TestDelegate()); |
| 104 // Make delegate_ exit the MessageLoop when the request is done. | 104 // Make delegate_ exit the MessageLoop when the request is done. |
| 105 delegate_->set_quit_on_complete(true); | 105 delegate_->set_quit_on_complete(true); |
| 106 delegate_->set_quit_on_redirect(true); | 106 delegate_->set_quit_on_redirect(true); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 135 | 135 |
| 136 void TestRequestNoRun(const GURL& url) { | 136 void TestRequestNoRun(const GURL& url) { |
| 137 TestRequestHelper(url, NULL, false, file_system_context_.get()); | 137 TestRequestHelper(url, NULL, false, file_system_context_.get()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void CreateDirectory(const base::StringPiece& dir_name) { | 140 void CreateDirectory(const base::StringPiece& dir_name) { |
| 141 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( | 141 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( |
| 142 GURL("http://remote"), | 142 GURL("http://remote"), |
| 143 fileapi::kFileSystemTypeTemporary, | 143 fileapi::kFileSystemTypeTemporary, |
| 144 base::FilePath().AppendASCII(dir_name)); | 144 base::FilePath().AppendASCII(dir_name)); |
| 145 ASSERT_EQ(base::PLATFORM_FILE_OK, AsyncFileTestHelper::CreateDirectory( | 145 ASSERT_EQ(base::File::FILE_OK, AsyncFileTestHelper::CreateDirectory( |
| 146 file_system_context_, url)); | 146 file_system_context_, url)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void WriteFile(const base::StringPiece& file_name, | 149 void WriteFile(const base::StringPiece& file_name, |
| 150 const char* buf, int buf_size) { | 150 const char* buf, int buf_size) { |
| 151 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( | 151 FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( |
| 152 GURL("http://remote"), | 152 GURL("http://remote"), |
| 153 fileapi::kFileSystemTypeTemporary, | 153 fileapi::kFileSystemTypeTemporary, |
| 154 base::FilePath().AppendASCII(file_name)); | 154 base::FilePath().AppendASCII(file_name)); |
| 155 ASSERT_EQ(base::PLATFORM_FILE_OK, | 155 ASSERT_EQ(base::File::FILE_OK, |
| 156 AsyncFileTestHelper::CreateFileWithData( | 156 AsyncFileTestHelper::CreateFileWithData( |
| 157 file_system_context_, url, buf, buf_size)); | 157 file_system_context_, url, buf, buf_size)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 GURL CreateFileSystemURL(const std::string& path) { | 160 GURL CreateFileSystemURL(const std::string& path) { |
| 161 return GURL(kFileSystemURLPrefix + path); | 161 return GURL(kFileSystemURLPrefix + path); |
| 162 } | 162 } |
| 163 | 163 |
| 164 static net::URLRequestJob* FileSystemURLRequestJobFactory( | 164 static net::URLRequestJob* FileSystemURLRequestJobFactory( |
| 165 net::URLRequest* request, | 165 net::URLRequest* request, |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 364 |
| 365 // Make sure it returns success with regular (non-incognito) context. | 365 // Make sure it returns success with regular (non-incognito) context. |
| 366 TestRequest(CreateFileSystemURL("file")); | 366 TestRequest(CreateFileSystemURL("file")); |
| 367 ASSERT_FALSE(request_->is_pending()); | 367 ASSERT_FALSE(request_->is_pending()); |
| 368 EXPECT_EQ(kTestFileData, delegate_->data_received()); | 368 EXPECT_EQ(kTestFileData, delegate_->data_received()); |
| 369 EXPECT_EQ(200, request_->GetResponseCode()); | 369 EXPECT_EQ(200, request_->GetResponseCode()); |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace | 372 } // namespace |
| 373 } // namespace content | 373 } // namespace content |
| OLD | NEW |