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 "chrome/browser/chromeos/drive/drive_url_request_job.h" | 5 #include "chrome/browser/chromeos/drive/drive_url_request_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h" | 14 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h" |
15 #include "chrome/browser/chromeos/drive/fake_file_system.h" | 15 #include "chrome/browser/chromeos/drive/fake_file_system.h" |
16 #include "chrome/browser/chromeos/drive/file_system_util.h" | 16 #include "chrome/browser/chromeos/drive/file_system_util.h" |
17 #include "chrome/browser/chromeos/drive/test_util.h" | 17 #include "chrome/browser/chromeos/drive/test_util.h" |
18 #include "chrome/browser/drive/fake_drive_service.h" | 18 #include "chrome/browser/drive/fake_drive_service.h" |
19 #include "chrome/browser/drive/test_util.h" | 19 #include "chrome/browser/drive/test_util.h" |
20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
23 #include "google_apis/drive/test_util.h" | 23 #include "google_apis/drive/test_util.h" |
24 #include "net/base/request_priority.h" | 24 #include "net/base/request_priority.h" |
25 #include "net/base/test_completion_callback.h" | 25 #include "net/base/test_completion_callback.h" |
26 #include "net/http/http_byte_range.h" | 26 #include "net/http/http_byte_range.h" |
| 27 #include "net/url_request/redirect_info.h" |
27 #include "net/url_request/url_request_test_util.h" | 28 #include "net/url_request/url_request_test_util.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
30 | 31 |
31 namespace drive { | 32 namespace drive { |
32 namespace { | 33 namespace { |
33 | 34 |
34 // A simple URLRequestJobFactory implementation to create DriveURLRequestJob. | 35 // A simple URLRequestJobFactory implementation to create DriveURLRequestJob. |
35 class TestURLRequestJobFactory : public net::URLRequestJobFactory { | 36 class TestURLRequestJobFactory : public net::URLRequestJobFactory { |
36 public: | 37 public: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 }; | 75 }; |
75 | 76 |
76 class TestDelegate : public net::TestDelegate { | 77 class TestDelegate : public net::TestDelegate { |
77 public: | 78 public: |
78 TestDelegate() {} | 79 TestDelegate() {} |
79 | 80 |
80 const GURL& redirect_url() const { return redirect_url_; } | 81 const GURL& redirect_url() const { return redirect_url_; } |
81 | 82 |
82 // net::TestDelegate override. | 83 // net::TestDelegate override. |
83 virtual void OnReceivedRedirect(net::URLRequest* request, | 84 virtual void OnReceivedRedirect(net::URLRequest* request, |
84 const GURL& new_url, | 85 const net::RedirectInfo& redirect_info, |
85 bool* defer_redirect) OVERRIDE{ | 86 bool* defer_redirect) OVERRIDE{ |
86 redirect_url_ = new_url; | 87 redirect_url_ = redirect_info.new_url; |
87 net::TestDelegate::OnReceivedRedirect(request, new_url, defer_redirect); | 88 net::TestDelegate::OnReceivedRedirect( |
| 89 request, redirect_info, defer_redirect); |
88 } | 90 } |
89 | 91 |
90 private: | 92 private: |
91 GURL redirect_url_; | 93 GURL redirect_url_; |
92 | 94 |
93 DISALLOW_COPY_AND_ASSIGN(TestDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(TestDelegate); |
94 }; | 96 }; |
95 | 97 |
96 } // namespace | 98 } // namespace |
97 | 99 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 "Range", "Wrong Range Header Value", false /* overwrite */); | 371 "Range", "Wrong Range Header Value", false /* overwrite */); |
370 request.Start(); | 372 request.Start(); |
371 | 373 |
372 base::RunLoop().Run(); | 374 base::RunLoop().Run(); |
373 | 375 |
374 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); | 376 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); |
375 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, request.status().error()); | 377 EXPECT_EQ(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, request.status().error()); |
376 } | 378 } |
377 | 379 |
378 } // namespace drive | 380 } // namespace drive |
OLD | NEW |