| 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 "native_test_server.h" | 5 #include "native_test_server.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Path where dictionaries are stored. | 49 // Path where dictionaries are stored. |
| 50 const char kSdchDictPath[] = "/sdch/dict/"; | 50 const char kSdchDictPath[] = "/sdch/dict/"; |
| 51 | 51 |
| 52 net::test_server::EmbeddedTestServer* g_test_server = nullptr; | 52 net::test_server::EmbeddedTestServer* g_test_server = nullptr; |
| 53 | 53 |
| 54 class CustomHttpResponse : public net::test_server::HttpResponse { | 54 class CustomHttpResponse : public net::test_server::HttpResponse { |
| 55 public: | 55 public: |
| 56 CustomHttpResponse(const std::string& headers, const std::string& contents) | 56 CustomHttpResponse(const std::string& headers, const std::string& contents) |
| 57 : headers_(headers), contents_(contents) {} | 57 : headers_(headers), contents_(contents) {} |
| 58 | 58 |
| 59 std::string ToResponseString() const override { | 59 void SendResponse(net::test_server::SendCallback send, |
| 60 return headers_ + "\r\n" + contents_; | 60 net::test_server::SendDoneCallback done) override { |
| 61 send.Run(headers_ + "\r\n" + contents_, done); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void AddHeader(const std::string& key_value_pair) { | 64 void AddHeader(const std::string& key_value_pair) { |
| 64 headers_.append(base::StringPrintf("%s\r\n", key_value_pair.c_str())); | 65 headers_.append(base::StringPrintf("%s\r\n", key_value_pair.c_str())); |
| 65 } | 66 } |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 std::string headers_; | 69 std::string headers_; |
| 69 std::string contents_; | 70 std::string contents_; |
| 70 | 71 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 #else | 334 #else |
| 334 return JNI_FALSE; | 335 return JNI_FALSE; |
| 335 #endif | 336 #endif |
| 336 } | 337 } |
| 337 | 338 |
| 338 bool RegisterNativeTestServer(JNIEnv* env) { | 339 bool RegisterNativeTestServer(JNIEnv* env) { |
| 339 return RegisterNativesImpl(env); | 340 return RegisterNativesImpl(env); |
| 340 } | 341 } |
| 341 | 342 |
| 342 } // namespace cronet | 343 } // namespace cronet |
| OLD | NEW |