| 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 <stdint.h> |    5 #include <stdint.h> | 
|    6 #include <limits> |    6 #include <limits> | 
|    7 #include <string> |    7 #include <string> | 
|    8 #include <utility> |    8 #include <utility> | 
|    9 #include <vector> |    9 #include <vector> | 
|   10  |   10  | 
|   11 #include "base/bind.h" |   11 #include "base/bind.h" | 
|   12 #include "base/bind_helpers.h" |   12 #include "base/bind_helpers.h" | 
|   13 #include "base/files/scoped_temp_dir.h" |   13 #include "base/files/scoped_temp_dir.h" | 
|   14 #include "base/location.h" |   14 #include "base/location.h" | 
|   15 #include "base/macros.h" |   15 #include "base/macros.h" | 
|   16 #include "base/memory/weak_ptr.h" |   16 #include "base/memory/weak_ptr.h" | 
|   17 #include "base/run_loop.h" |   17 #include "base/run_loop.h" | 
|   18 #include "base/single_thread_task_runner.h" |   18 #include "base/single_thread_task_runner.h" | 
|   19 #include "base/threading/thread_task_runner_handle.h" |   19 #include "base/threading/thread_task_runner_handle.h" | 
|   20 #include "content/public/test/async_file_test_helper.h" |   20 #include "content/public/test/async_file_test_helper.h" | 
|   21 #include "content/public/test/test_file_system_context.h" |   21 #include "content/public/test/test_file_system_context.h" | 
|   22 #include "net/base/io_buffer.h" |   22 #include "net/base/io_buffer.h" | 
|   23 #include "net/base/request_priority.h" |   23 #include "net/base/request_priority.h" | 
 |   24 #include "net/http/http_response_headers.h" | 
 |   25 #include "net/http/http_response_info.h" | 
|   24 #include "net/url_request/url_request.h" |   26 #include "net/url_request/url_request.h" | 
|   25 #include "net/url_request/url_request_context.h" |   27 #include "net/url_request/url_request_context.h" | 
|   26 #include "net/url_request/url_request_job.h" |   28 #include "net/url_request/url_request_job.h" | 
|   27 #include "net/url_request/url_request_job_factory.h" |   29 #include "net/url_request/url_request_job_factory.h" | 
|   28 #include "net/url_request/url_request_status.h" |   30 #include "net/url_request/url_request_status.h" | 
|   29 #include "storage/browser/fileapi/file_system_context.h" |   31 #include "storage/browser/fileapi/file_system_context.h" | 
|   30 #include "storage/browser/fileapi/file_system_quota_util.h" |   32 #include "storage/browser/fileapi/file_system_quota_util.h" | 
|   31 #include "storage/browser/fileapi/file_writer_delegate.h" |   33 #include "storage/browser/fileapi/file_writer_delegate.h" | 
|   32 #include "storage/browser/fileapi/sandbox_file_stream_writer.h" |   34 #include "storage/browser/fileapi/sandbox_file_stream_writer.h" | 
|   33 #include "storage/common/fileapi/file_system_mount_option.h" |   35 #include "storage/common/fileapi/file_system_mount_option.h" | 
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  193     if (remaining_bytes_ < buf_size) |  195     if (remaining_bytes_ < buf_size) | 
|  194       buf_size = remaining_bytes_; |  196       buf_size = remaining_bytes_; | 
|  195  |  197  | 
|  196     for (int i = 0; i < buf_size; ++i) |  198     for (int i = 0; i < buf_size; ++i) | 
|  197       buf->data()[i] = content_[cursor_++]; |  199       buf->data()[i] = content_[cursor_++]; | 
|  198     remaining_bytes_ -= buf_size; |  200     remaining_bytes_ -= buf_size; | 
|  199  |  201  | 
|  200     return buf_size; |  202     return buf_size; | 
|  201   } |  203   } | 
|  202  |  204  | 
|  203   int GetResponseCode() const override { return 200; } |  205   void GetResponseInfo(net::HttpResponseInfo* info) override { | 
 |  206     *info = net::HttpResponseInfo(); | 
 |  207     std::string headers = "HTTP/1.1 200 OK"; | 
 |  208     info->headers = new net::HttpResponseHeaders( | 
 |  209         net::HttpUtil::AssembleRawHeaders(headers.c_str(), headers.size())); | 
 |  210   } | 
|  204  |  211  | 
|  205  protected: |  212  protected: | 
|  206   ~FileWriterDelegateTestJob() override {} |  213   ~FileWriterDelegateTestJob() override {} | 
|  207  |  214  | 
|  208  private: |  215  private: | 
|  209   std::string content_; |  216   std::string content_; | 
|  210   int remaining_bytes_; |  217   int remaining_bytes_; | 
|  211   int cursor_; |  218   int cursor_; | 
|  212  |  219  | 
|  213   base::WeakPtrFactory<FileWriterDelegateTestJob> weak_factory_; |  220   base::WeakPtrFactory<FileWriterDelegateTestJob> weak_factory_; | 
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  500     file_writer_delegate_.reset(); |  507     file_writer_delegate_.reset(); | 
|  501  |  508  | 
|  502     EXPECT_EQ(pre_write_usage + allowed_growth, usage()); |  509     EXPECT_EQ(pre_write_usage + allowed_growth, usage()); | 
|  503     EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |  510     EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 
|  504     EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); |  511     EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); | 
|  505     EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); |  512     EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); | 
|  506   } |  513   } | 
|  507 } |  514 } | 
|  508  |  515  | 
|  509 }  // namespace content |  516 }  // namespace content | 
| OLD | NEW |