| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/android/url_request_content_job.h" | 5 #include "content/browser/android/url_request_content_job.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
| 10 | 11 |
| 11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/test/test_file_util.h" | 15 #include "base/test/test_file_util.h" |
| 16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // return the content URI. | 142 // return the content URI. |
| 143 base::FilePath path = base::InsertImageIntoMediaStore(image_file); | 143 base::FilePath path = base::InsertImageIntoMediaStore(image_file); |
| 144 EXPECT_TRUE(path.IsContentUri()); | 144 EXPECT_TRUE(path.IsContentUri()); |
| 145 EXPECT_TRUE(base::PathExists(path)); | 145 EXPECT_TRUE(base::PathExists(path)); |
| 146 int64_t file_size; | 146 int64_t file_size; |
| 147 EXPECT_TRUE(base::GetFileSize(path, &file_size)); | 147 EXPECT_TRUE(base::GetFileSize(path, &file_size)); |
| 148 EXPECT_LT(0, file_size); | 148 EXPECT_LT(0, file_size); |
| 149 CallbacksJobFactory factory(path, &observer_); | 149 CallbacksJobFactory factory(path, &observer_); |
| 150 context_.set_job_factory(&factory); | 150 context_.set_job_factory(&factory); |
| 151 | 151 |
| 152 scoped_ptr<net::URLRequest> request(context_.CreateRequest( | 152 std::unique_ptr<net::URLRequest> request(context_.CreateRequest( |
| 153 GURL(path.value()), net::DEFAULT_PRIORITY, &delegate_)); | 153 GURL(path.value()), net::DEFAULT_PRIORITY, &delegate_)); |
| 154 int expected_length = file_size; | 154 int expected_length = file_size; |
| 155 if (range) { | 155 if (range) { |
| 156 ASSERT_GE(range->start, 0); | 156 ASSERT_GE(range->start, 0); |
| 157 ASSERT_GE(range->end, 0); | 157 ASSERT_GE(range->end, 0); |
| 158 ASSERT_LE(range->start, range->end); | 158 ASSERT_LE(range->start, range->end); |
| 159 std::string range_value = | 159 std::string range_value = |
| 160 base::StringPrintf("bytes=%d-%d", range->start, range->end); | 160 base::StringPrintf("bytes=%d-%d", range->start, range->end); |
| 161 request->SetExtraRequestHeaderByName( | 161 request->SetExtraRequestHeaderByName( |
| 162 net::HttpRequestHeaders::kRange, range_value, true /*overwrite*/); | 162 net::HttpRequestHeaders::kRange, range_value, true /*overwrite*/); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 192 } | 192 } |
| 193 | 193 |
| 194 TEST_F(URLRequestContentJobTest, ContentURIWithZeroRange) { | 194 TEST_F(URLRequestContentJobTest, ContentURIWithZeroRange) { |
| 195 Range range(0, 0); | 195 Range range(0, 0); |
| 196 RunRequest(&range); | 196 RunRequest(&range); |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace | 199 } // namespace |
| 200 | 200 |
| 201 } // namespace content | 201 } // namespace content |
| OLD | NEW |