| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 13 #include "base/safe_numerics.h" | |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "content/public/test/test_file_system_context.h" | 15 #include "content/public/test/test_file_system_context.h" |
| 16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 17 #include "net/base/request_priority.h" | 17 #include "net/base/request_priority.h" |
| 18 #include "net/http/http_byte_range.h" | 18 #include "net/http/http_byte_range.h" |
| 19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
| 20 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
| 21 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
| 22 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 23 #include "net/url_request/url_request_job_factory_impl.h" | 23 #include "net/url_request/url_request_job_factory_impl.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 *expected_result += std::string(kTestFileSystemFileData2 + 6, 7); | 280 *expected_result += std::string(kTestFileSystemFileData2 + 6, 7); |
| 281 } | 281 } |
| 282 | 282 |
| 283 // This only works if all the Blob items have a definite pre-computed length. | 283 // This only works if all the Blob items have a definite pre-computed length. |
| 284 // Otherwise, this will fail a CHECK. | 284 // Otherwise, this will fail a CHECK. |
| 285 int64 GetTotalBlobLength() const { | 285 int64 GetTotalBlobLength() const { |
| 286 int64 total = 0; | 286 int64 total = 0; |
| 287 const std::vector<BlobData::Item>& items = blob_data_->items(); | 287 const std::vector<BlobData::Item>& items = blob_data_->items(); |
| 288 for (std::vector<BlobData::Item>::const_iterator it = items.begin(); | 288 for (std::vector<BlobData::Item>::const_iterator it = items.begin(); |
| 289 it != items.end(); ++it) { | 289 it != items.end(); ++it) { |
| 290 int64 length = base::checked_numeric_cast<int64>(it->length()); | 290 int64 length = base::checked_cast<int64>(it->length()); |
| 291 CHECK(length <= kint64max - total); | 291 CHECK(length <= kint64max - total); |
| 292 total += length; | 292 total += length; |
| 293 } | 293 } |
| 294 return total; | 294 return total; |
| 295 } | 295 } |
| 296 | 296 |
| 297 protected: | 297 protected: |
| 298 base::ScopedTempDir temp_dir_; | 298 base::ScopedTempDir temp_dir_; |
| 299 base::FilePath temp_file1_; | 299 base::FilePath temp_file1_; |
| 300 base::FilePath temp_file2_; | 300 base::FilePath temp_file2_; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); | 471 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); |
| 472 EXPECT_EQ(kTestContentType, content_type); | 472 EXPECT_EQ(kTestContentType, content_type); |
| 473 void* iter = NULL; | 473 void* iter = NULL; |
| 474 std::string content_disposition; | 474 std::string content_disposition; |
| 475 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( | 475 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( |
| 476 &iter, "Content-Disposition", &content_disposition)); | 476 &iter, "Content-Disposition", &content_disposition)); |
| 477 EXPECT_EQ(kTestContentDisposition, content_disposition); | 477 EXPECT_EQ(kTestContentDisposition, content_disposition); |
| 478 } | 478 } |
| 479 | 479 |
| 480 } // namespace content | 480 } // namespace content |
| OLD | NEW |