| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 *expected_result += std::string(kTestFileSystemFileData2 + 6, 7); | 277 *expected_result += std::string(kTestFileSystemFileData2 + 6, 7); |
| 278 } | 278 } |
| 279 | 279 |
| 280 // This only works if all the Blob items have a definite pre-computed length. | 280 // This only works if all the Blob items have a definite pre-computed length. |
| 281 // Otherwise, this will fail a CHECK. | 281 // Otherwise, this will fail a CHECK. |
| 282 int64 GetTotalBlobLength() const { | 282 int64 GetTotalBlobLength() const { |
| 283 int64 total = 0; | 283 int64 total = 0; |
| 284 const std::vector<BlobData::Item>& items = blob_data_->items(); | 284 const std::vector<BlobData::Item>& items = blob_data_->items(); |
| 285 for (std::vector<BlobData::Item>::const_iterator it = items.begin(); | 285 for (std::vector<BlobData::Item>::const_iterator it = items.begin(); |
| 286 it != items.end(); ++it) { | 286 it != items.end(); ++it) { |
| 287 int64 length = base::checked_numeric_cast<int64>(it->length()); | 287 int64 length = base::checked_cast<int64>(it->length()); |
| 288 CHECK(length <= kint64max - total); | 288 CHECK(length <= kint64max - total); |
| 289 total += length; | 289 total += length; |
| 290 } | 290 } |
| 291 return total; | 291 return total; |
| 292 } | 292 } |
| 293 | 293 |
| 294 protected: | 294 protected: |
| 295 base::ScopedTempDir temp_dir_; | 295 base::ScopedTempDir temp_dir_; |
| 296 base::FilePath temp_file1_; | 296 base::FilePath temp_file1_; |
| 297 base::FilePath temp_file2_; | 297 base::FilePath temp_file2_; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); | 468 EXPECT_TRUE(request_->response_headers()->GetMimeType(&content_type)); |
| 469 EXPECT_EQ(kTestContentType, content_type); | 469 EXPECT_EQ(kTestContentType, content_type); |
| 470 void* iter = NULL; | 470 void* iter = NULL; |
| 471 std::string content_disposition; | 471 std::string content_disposition; |
| 472 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( | 472 EXPECT_TRUE(request_->response_headers()->EnumerateHeader( |
| 473 &iter, "Content-Disposition", &content_disposition)); | 473 &iter, "Content-Disposition", &content_disposition)); |
| 474 EXPECT_EQ(kTestContentDisposition, content_disposition); | 474 EXPECT_EQ(kTestContentDisposition, content_disposition); |
| 475 } | 475 } |
| 476 | 476 |
| 477 } // namespace webkit_blob | 477 } // namespace webkit_blob |
| OLD | NEW |