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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|, | 131 // Creates and sets up a FileWriterDelegate for writing the given |blob_url|, |
132 // and creates a new FileWriterDelegate for the file. | 132 // and creates a new FileWriterDelegate for the file. |
133 void PrepareForWrite(const char* test_file_path, | 133 void PrepareForWrite(const char* test_file_path, |
134 const GURL& blob_url, | 134 const GURL& blob_url, |
135 int64 offset, | 135 int64 offset, |
136 int64 allowed_growth) { | 136 int64 allowed_growth) { |
137 file_writer_delegate_.reset( | 137 file_writer_delegate_.reset( |
138 CreateWriterDelegate(test_file_path, offset, allowed_growth)); | 138 CreateWriterDelegate(test_file_path, offset, allowed_growth)); |
139 request_ = empty_context_.CreateRequest( | 139 request_ = empty_context_.CreateRequest( |
140 blob_url, net::DEFAULT_PRIORITY, file_writer_delegate_.get()); | 140 blob_url, net::DEFAULT_PRIORITY, file_writer_delegate_.get(), NULL); |
141 } | 141 } |
142 | 142 |
143 static net::URLRequest::ProtocolFactory Factory; | 143 static net::URLRequest::ProtocolFactory Factory; |
144 | 144 |
145 // This should be alive until the very end of this instance. | 145 // This should be alive until the very end of this instance. |
146 base::MessageLoopForIO loop_; | 146 base::MessageLoopForIO loop_; |
147 | 147 |
148 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 148 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
149 | 149 |
150 net::URLRequestContext empty_context_; | 150 net::URLRequestContext empty_context_; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 const GURL kBlobURL("blob:nolimitconcurrent"); | 328 const GURL kBlobURL("blob:nolimitconcurrent"); |
329 const GURL kBlobURL2("blob:nolimitconcurrent2"); | 329 const GURL kBlobURL2("blob:nolimitconcurrent2"); |
330 content_ = kData; | 330 content_ = kData; |
331 | 331 |
332 PrepareForWrite("test", kBlobURL, 0, kint64max); | 332 PrepareForWrite("test", kBlobURL, 0, kint64max); |
333 | 333 |
334 // Credate another FileWriterDelegate for concurrent write. | 334 // Credate another FileWriterDelegate for concurrent write. |
335 file_writer_delegate2.reset(CreateWriterDelegate("test2", 0, kint64max)); | 335 file_writer_delegate2.reset(CreateWriterDelegate("test2", 0, kint64max)); |
336 request2 = empty_context_.CreateRequest( | 336 request2 = empty_context_.CreateRequest( |
337 kBlobURL2, net::DEFAULT_PRIORITY, file_writer_delegate2.get()); | 337 kBlobURL2, net::DEFAULT_PRIORITY, file_writer_delegate2.get(), NULL); |
338 | 338 |
339 Result result, result2; | 339 Result result, result2; |
340 ASSERT_EQ(0, usage()); | 340 ASSERT_EQ(0, usage()); |
341 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); | 341 file_writer_delegate_->Start(request_.Pass(), GetWriteCallback(&result)); |
342 file_writer_delegate2->Start(request2.Pass(), GetWriteCallback(&result2)); | 342 file_writer_delegate2->Start(request2.Pass(), GetWriteCallback(&result2)); |
343 base::MessageLoop::current()->Run(); | 343 base::MessageLoop::current()->Run(); |
344 if (result.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING || | 344 if (result.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING || |
345 result2.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING) | 345 result2.write_status() == FileWriterDelegate::SUCCESS_IO_PENDING) |
346 base::MessageLoop::current()->Run(); | 346 base::MessageLoop::current()->Run(); |
347 | 347 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 file_writer_delegate_.reset(); | 452 file_writer_delegate_.reset(); |
453 | 453 |
454 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); | 454 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); |
455 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 455 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
456 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); | 456 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); |
457 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); | 457 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
461 } // namespace content | 461 } // namespace content |
OLD | NEW |