| 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/fileapi/file_system_url_request_job.h" | 5 #include "webkit/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_path.h" | 10 #include "base/file_path.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 ASSERT_EQ(base::PLATFORM_FILE_OK, result); | 103 ASSERT_EQ(base::PLATFORM_FILE_OK, result); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void TestRequestHelper(const GURL& url, | 106 void TestRequestHelper(const GURL& url, |
| 107 const net::HttpRequestHeaders* headers, | 107 const net::HttpRequestHeaders* headers, |
| 108 bool run_to_completion) { | 108 bool run_to_completion) { |
| 109 delegate_.reset(new TestDelegate()); | 109 delegate_.reset(new TestDelegate()); |
| 110 // Make delegate_ exit the MessageLoop when the request is done. | 110 // Make delegate_ exit the MessageLoop when the request is done. |
| 111 delegate_->set_quit_on_complete(true); | 111 delegate_->set_quit_on_complete(true); |
| 112 delegate_->set_quit_on_redirect(true); | 112 delegate_->set_quit_on_redirect(true); |
| 113 request_.reset(new net::URLRequest(url, delegate_.get())); | 113 request_.reset( |
| 114 new net::URLRequest(url, delegate_.get(), &empty_context_)); |
| 114 if (headers) | 115 if (headers) |
| 115 request_->SetExtraRequestHeaders(*headers); | 116 request_->SetExtraRequestHeaders(*headers); |
| 116 ASSERT_TRUE(!job_); | 117 ASSERT_TRUE(!job_); |
| 117 job_ = new FileSystemURLRequestJob( | 118 job_ = new FileSystemURLRequestJob( |
| 118 request_.get(), | 119 request_.get(), |
| 119 file_system_context_.get()); | 120 file_system_context_.get()); |
| 120 pending_job_ = job_; | 121 pending_job_ = job_; |
| 121 | 122 |
| 122 request_->Start(); | 123 request_->Start(); |
| 123 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async | 124 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 203 } |
| 203 | 204 |
| 204 // Put the message loop at the top, so that it's the last thing deleted. | 205 // Put the message loop at the top, so that it's the last thing deleted. |
| 205 MessageLoop message_loop_; | 206 MessageLoop message_loop_; |
| 206 | 207 |
| 207 ScopedTempDir temp_dir_; | 208 ScopedTempDir temp_dir_; |
| 208 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; | 209 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; |
| 209 scoped_refptr<FileSystemContext> file_system_context_; | 210 scoped_refptr<FileSystemContext> file_system_context_; |
| 210 base::WeakPtrFactory<FileSystemURLRequestJobTest> weak_factory_; | 211 base::WeakPtrFactory<FileSystemURLRequestJobTest> weak_factory_; |
| 211 | 212 |
| 213 net::URLRequestContext empty_context_; |
| 214 |
| 212 // NOTE: order matters, request must die before delegate | 215 // NOTE: order matters, request must die before delegate |
| 213 scoped_ptr<TestDelegate> delegate_; | 216 scoped_ptr<TestDelegate> delegate_; |
| 214 scoped_ptr<net::URLRequest> request_; | 217 scoped_ptr<net::URLRequest> request_; |
| 215 | 218 |
| 216 scoped_refptr<net::URLRequestJob> pending_job_; | 219 scoped_refptr<net::URLRequestJob> pending_job_; |
| 217 static net::URLRequestJob* job_; | 220 static net::URLRequestJob* job_; |
| 218 }; | 221 }; |
| 219 | 222 |
| 220 // static | 223 // static |
| 221 net::URLRequestJob* FileSystemURLRequestJobTest::job_ = NULL; | 224 net::URLRequestJob* FileSystemURLRequestJobTest::job_ = NULL; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 366 |
| 364 TestRequest(CreateFileSystemURL(kFilename)); | 367 TestRequest(CreateFileSystemURL(kFilename)); |
| 365 | 368 |
| 366 std::string mime_type_from_job; | 369 std::string mime_type_from_job; |
| 367 request_->GetMimeType(&mime_type_from_job); | 370 request_->GetMimeType(&mime_type_from_job); |
| 368 EXPECT_EQ(mime_type_direct, mime_type_from_job); | 371 EXPECT_EQ(mime_type_direct, mime_type_from_job); |
| 369 } | 372 } |
| 370 | 373 |
| 371 } // namespace | 374 } // namespace |
| 372 } // namespace fileapi | 375 } // namespace fileapi |
| OLD | NEW |