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 #ifndef IOS_WEB_PUBLIC_TEST_HTTP_SERVER_HTTP_SERVER_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_HTTP_SERVER_HTTP_SERVER_H_ |
| 6 #define IOS_WEB_PUBLIC_TEST_HTTP_SERVER_HTTP_SERVER_H_ | 6 #define IOS_WEB_PUBLIC_TEST_HTTP_SERVER_HTTP_SERVER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 // Starts the server on the default port 8080. CHECKs if the server can not be | 73 // Starts the server on the default port 8080. CHECKs if the server can not be |
| 74 // started. | 74 // started. |
| 75 // Must be called from the main thread. | 75 // Must be called from the main thread. |
| 76 void StartOrDie(); | 76 void StartOrDie(); |
| 77 // Stops the server and prevents it from accepting new requests. | 77 // Stops the server and prevents it from accepting new requests. |
| 78 // Must be called from the main thread. | 78 // Must be called from the main thread. |
| 79 void Stop(); | 79 void Stop(); |
| 80 // Returns true if the server is running. | 80 // Returns true if the server is running. |
| 81 // Must be called from the main thread. | 81 // Must be called from the main thread. |
| 82 bool IsRunning() const; | 82 bool IsRunning() const; |
| 83 // Sets the server to hang and return no response. | |
| 84 void setSuspend(BOOL suspended); | |
|
baxley
2017/06/06 18:14:17
would it be more consistent if this is "bool"? wha
huangml1
2017/06/07 18:10:54
I feel that setSuspend is more like an action than
baxley
2017/06/07 18:21:06
I meant more that the rest of this is C++. If the
| |
| 83 | 85 |
| 84 // Returns the port that the server is running on. Thread Safe | 86 // Returns the port that the server is running on. Thread Safe |
| 85 NSUInteger GetPort() const; | 87 NSUInteger GetPort() const; |
| 86 | 88 |
| 87 // Adds a ResponseProvider. Takes ownership of the ResponseProvider. | 89 // Adds a ResponseProvider. Takes ownership of the ResponseProvider. |
| 88 // Note for using URLs inside of the |response_provider|: | 90 // Note for using URLs inside of the |response_provider|: |
| 89 // The HttpServer cannot run on default HTTP port 80, so URLs used in | 91 // The HttpServer cannot run on default HTTP port 80, so URLs used in |
| 90 // ResponseProviders must be converted at runtime after the HttpServer's port | 92 // ResponseProviders must be converted at runtime after the HttpServer's port |
| 91 // is determined. Please use |MakeUrl| to handle converting URLs. | 93 // is determined. Please use |MakeUrl| to handle converting URLs. |
| 92 // Must be called from the main thread. | 94 // Must be called from the main thread. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 std::vector<scoped_refptr<RefCountedResponseProviderWrapper>> providers_; | 131 std::vector<scoped_refptr<RefCountedResponseProviderWrapper>> providers_; |
| 130 // Returns the response providers for a request. | 132 // Returns the response providers for a request. |
| 131 ResponseProvider* GetResponseProviderForProviderRequest( | 133 ResponseProvider* GetResponseProviderForProviderRequest( |
| 132 const web::ResponseProvider::Request& request); | 134 const web::ResponseProvider::Request& request); |
| 133 // Provides a shim between EmbeddedTestServer and ResponseProvider. This | 135 // Provides a shim between EmbeddedTestServer and ResponseProvider. This |
| 134 // handler converts an EmbeddedTestServer request to ResponseProvider | 136 // handler converts an EmbeddedTestServer request to ResponseProvider |
| 135 // request, look up the corresponding providers, and then converts the | 137 // request, look up the corresponding providers, and then converts the |
| 136 // ResponseProvider response back to EmbeddedTestServer response. | 138 // ResponseProvider response back to EmbeddedTestServer response. |
| 137 std::unique_ptr<net::test_server::HttpResponse> GetResponse( | 139 std::unique_ptr<net::test_server::HttpResponse> GetResponse( |
| 138 const net::test_server::HttpRequest& request); | 140 const net::test_server::HttpRequest& request); |
| 141 // The status that if the server hangs. | |
|
baxley
2017/06/06 18:14:17
"Status tracking if the server is hung."
huangml1
2017/06/07 18:10:54
Done.
| |
| 142 BOOL isSuspended; | |
|
baxley
2017/06/06 18:14:17
bool?
huangml1
2017/06/07 18:10:54
Done.
| |
| 139 DISALLOW_COPY_AND_ASSIGN(HttpServer); | 143 DISALLOW_COPY_AND_ASSIGN(HttpServer); |
| 140 }; | 144 }; |
| 141 | 145 |
| 142 } // namespace test | 146 } // namespace test |
| 143 } // namspace web | 147 } // namspace web |
| 144 | 148 |
| 145 #endif // IOS_WEB_PUBLIC_TEST_HTTP_SERVER_HTTP_SERVER_H_ | 149 #endif // IOS_WEB_PUBLIC_TEST_HTTP_SERVER_HTTP_SERVER_H_ |
| OLD | NEW |