Chromium Code Reviews| 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 #include <memory> |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 | 40 |
| 41 net::URLRequestJob* MaybeCreateJobWithProtocolHandler( | 41 net::URLRequestJob* MaybeCreateJobWithProtocolHandler( |
| 42 const std::string& scheme, | 42 const std::string& scheme, |
| 43 net::URLRequest* request, | 43 net::URLRequest* request, |
| 44 net::NetworkDelegate* network_delegate) const override { | 44 net::NetworkDelegate* network_delegate) const override { |
| 45 URLRequestContentJob* job = | 45 URLRequestContentJob* job = |
| 46 new URLRequestContentJob( | 46 new URLRequestContentJob( |
| 47 request, | 47 request, |
| 48 network_delegate, | 48 network_delegate, |
| 49 path_, | 49 path_, |
| 50 const_cast<base::MessageLoop*>(&message_loop_)->task_runner()); | 50 base::MessageLoop::current()->task_runner()); |
|
Ryan Sleevi
2016/11/07 16:21:38
Shouldn't this be https://cs.chromium.org/chromium
Randy Smith (Not in Mondays)
2016/11/07 16:58:09
Given the amount of pain switching over to TTRH co
Ryan Sleevi
2016/11/07 17:09:43
Well, this is directly being touched by you becaus
| |
| 51 observer_->OnJobCreated(); | 51 observer_->OnJobCreated(); |
| 52 return job; | 52 return job; |
| 53 } | 53 } |
| 54 | 54 |
| 55 net::URLRequestJob* MaybeInterceptRedirect( | 55 net::URLRequestJob* MaybeInterceptRedirect( |
| 56 net::URLRequest* request, | 56 net::URLRequest* request, |
| 57 net::NetworkDelegate* network_delegate, | 57 net::NetworkDelegate* network_delegate, |
| 58 const GURL& location) const override { | 58 const GURL& location) const override { |
| 59 return nullptr; | 59 return nullptr; |
| 60 } | 60 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 71 | 71 |
| 72 bool IsHandledURL(const GURL& url) const override { | 72 bool IsHandledURL(const GURL& url) const override { |
| 73 return IsHandledProtocol(url.scheme()); | 73 return IsHandledProtocol(url.scheme()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool IsSafeRedirectTarget(const GURL& location) const override { | 76 bool IsSafeRedirectTarget(const GURL& location) const override { |
| 77 return false; | 77 return false; |
| 78 } | 78 } |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 base::MessageLoop message_loop_; | |
| 82 base::FilePath path_; | 81 base::FilePath path_; |
| 83 JobObserver* observer_; | 82 JobObserver* observer_; |
| 84 }; | 83 }; |
| 85 | 84 |
| 86 class JobObserverImpl : public CallbacksJobFactory::JobObserver { | 85 class JobObserverImpl : public CallbacksJobFactory::JobObserver { |
| 87 public: | 86 public: |
| 88 JobObserverImpl() : num_jobs_created_(0) {} | 87 JobObserverImpl() : num_jobs_created_(0) {} |
| 89 ~JobObserverImpl() override {} | 88 ~JobObserverImpl() override {} |
| 90 | 89 |
| 91 void OnJobCreated() override { ++num_jobs_created_; } | 90 void OnJobCreated() override { ++num_jobs_created_; } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 114 URLRequestContentJobTest(); | 113 URLRequestContentJobTest(); |
| 115 | 114 |
| 116 protected: | 115 protected: |
| 117 // This inserts an image file into the android MediaStore and retrieves the | 116 // This inserts an image file into the android MediaStore and retrieves the |
| 118 // content URI. Then creates and runs a URLRequestContentJob to get the | 117 // content URI. Then creates and runs a URLRequestContentJob to get the |
| 119 // contents out of it. If a Range is provided, this function will add the | 118 // contents out of it. If a Range is provided, this function will add the |
| 120 // appropriate Range http header to the request and verify the bytes | 119 // appropriate Range http header to the request and verify the bytes |
| 121 // retrieved. | 120 // retrieved. |
| 122 void RunRequest(const Range* range); | 121 void RunRequest(const Range* range); |
| 123 | 122 |
| 123 base::MessageLoop message_loop_; | |
| 124 JobObserverImpl observer_; | 124 JobObserverImpl observer_; |
| 125 net::TestURLRequestContext context_; | 125 net::TestURLRequestContext context_; |
| 126 net::TestDelegate delegate_; | 126 net::TestDelegate delegate_; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 URLRequestContentJobTest::URLRequestContentJobTest() {} | 129 URLRequestContentJobTest::URLRequestContentJobTest() {} |
| 130 | 130 |
| 131 void URLRequestContentJobTest::RunRequest(const Range* range) { | 131 void URLRequestContentJobTest::RunRequest(const Range* range) { |
| 132 base::FilePath test_dir; | 132 base::FilePath test_dir; |
| 133 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir); | 133 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |