OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/web/public/test/http_server/delayed_response_provider.h" | 5 #import "ios/web/public/test/http_server/delayed_response_provider.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #import "base/ios/weak_nsobject.h" | |
11 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
12 #import "base/mac/scoped_nsobject.h" | |
13 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
15 #include "net/test/embedded_test_server/http_response.h" | 13 #include "net/test/embedded_test_server/http_response.h" |
16 | 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." |
| 17 #endif |
| 18 |
17 namespace web { | 19 namespace web { |
18 | 20 |
19 // Delays |delay| seconds before sending a response to the client. | 21 // Delays |delay| seconds before sending a response to the client. |
20 class DelayedHttpResponse : public net::test_server::BasicHttpResponse { | 22 class DelayedHttpResponse : public net::test_server::BasicHttpResponse { |
21 public: | 23 public: |
22 explicit DelayedHttpResponse(double delay) : delay_(delay) {} | 24 explicit DelayedHttpResponse(double delay) : delay_(delay) {} |
23 | 25 |
24 void SendResponse( | 26 void SendResponse( |
25 const net::test_server::SendBytesCallback& send, | 27 const net::test_server::SendBytesCallback& send, |
26 const net::test_server::SendCompleteCallback& done) override { | 28 const net::test_server::SendCompleteCallback& done) override { |
(...skipping 23 matching lines...) Expand all Loading... |
50 | 52 |
51 std::unique_ptr<net::test_server::HttpResponse> | 53 std::unique_ptr<net::test_server::HttpResponse> |
52 DelayedResponseProvider::GetEmbeddedTestServerResponse(const Request& request) { | 54 DelayedResponseProvider::GetEmbeddedTestServerResponse(const Request& request) { |
53 std::unique_ptr<net::test_server::BasicHttpResponse> http_response( | 55 std::unique_ptr<net::test_server::BasicHttpResponse> http_response( |
54 base::MakeUnique<DelayedHttpResponse>(delay_)); | 56 base::MakeUnique<DelayedHttpResponse>(delay_)); |
55 http_response->set_content_type("text/html"); | 57 http_response->set_content_type("text/html"); |
56 http_response->set_content("Slow Page"); | 58 http_response->set_content("Slow Page"); |
57 return std::move(http_response); | 59 return std::move(http_response); |
58 } | 60 } |
59 } // namespace web | 61 } // namespace web |
OLD | NEW |