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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 base::FilePath path = base::InsertImageIntoMediaStore(image_file); | 141 base::FilePath path = base::InsertImageIntoMediaStore(image_file); |
142 EXPECT_TRUE(path.IsContentUri()); | 142 EXPECT_TRUE(path.IsContentUri()); |
143 EXPECT_TRUE(base::PathExists(path)); | 143 EXPECT_TRUE(base::PathExists(path)); |
144 int64 file_size; | 144 int64 file_size; |
145 EXPECT_TRUE(base::GetFileSize(path, &file_size)); | 145 EXPECT_TRUE(base::GetFileSize(path, &file_size)); |
146 EXPECT_LT(0, file_size); | 146 EXPECT_LT(0, file_size); |
147 CallbacksJobFactory factory(path, &observer_); | 147 CallbacksJobFactory factory(path, &observer_); |
148 context_.set_job_factory(&factory); | 148 context_.set_job_factory(&factory); |
149 | 149 |
150 scoped_ptr<net::URLRequest> request(context_.CreateRequest( | 150 scoped_ptr<net::URLRequest> request(context_.CreateRequest( |
151 GURL(path.value()), net::DEFAULT_PRIORITY, &delegate_, NULL)); | 151 GURL(path.value()), net::DEFAULT_PRIORITY, &delegate_)); |
152 int expected_length = file_size; | 152 int expected_length = file_size; |
153 if (range) { | 153 if (range) { |
154 ASSERT_GE(range->start, 0); | 154 ASSERT_GE(range->start, 0); |
155 ASSERT_GE(range->end, 0); | 155 ASSERT_GE(range->end, 0); |
156 ASSERT_LE(range->start, range->end); | 156 ASSERT_LE(range->start, range->end); |
157 std::string range_value = | 157 std::string range_value = |
158 base::StringPrintf("bytes=%d-%d", range->start, range->end); | 158 base::StringPrintf("bytes=%d-%d", range->start, range->end); |
159 request->SetExtraRequestHeaderByName( | 159 request->SetExtraRequestHeaderByName( |
160 net::HttpRequestHeaders::kRange, range_value, true /*overwrite*/); | 160 net::HttpRequestHeaders::kRange, range_value, true /*overwrite*/); |
161 if (range->start <= file_size) | 161 if (range->start <= file_size) |
(...skipping 27 matching lines...) Expand all Loading... |
189 } | 189 } |
190 | 190 |
191 TEST_F(URLRequestContentJobTest, ContentURIWithZeroRange) { | 191 TEST_F(URLRequestContentJobTest, ContentURIWithZeroRange) { |
192 Range range(0, 0); | 192 Range range(0, 0); |
193 RunRequest(&range); | 193 RunRequest(&range); |
194 } | 194 } |
195 | 195 |
196 } // namespace | 196 } // namespace |
197 | 197 |
198 } // namespace content | 198 } // namespace content |
OLD | NEW |