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 "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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 // supports Sdch encoding. E.g. /sdch/index?q=LeQxM80O will make the server | 44 // supports Sdch encoding. E.g. /sdch/index?q=LeQxM80O will make the server |
| 45 // responds with "Get-Dictionary: /sdch/dict/LeQxM80O". | 45 // responds with "Get-Dictionary: /sdch/dict/LeQxM80O". |
| 46 const char kSdchPath[] = "/sdch/index"; | 46 const char kSdchPath[] = "/sdch/index"; |
| 47 // Path that returns encoded response if client has the right dictionary. | 47 // Path that returns encoded response if client has the right dictionary. |
| 48 const char kSdchTestPath[] = "/sdch/test"; | 48 const char kSdchTestPath[] = "/sdch/test"; |
| 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 { |
|
mmenke
2015/10/22 19:28:27
Suggest renaming this...There's no collision, but
svaldez
2015/10/22 20:00:17
Removing and implementing as RawHttpResponse.
| |
| 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( |
| 60 return headers_ + "\r\n" + contents_; | 60 const net::test_server::SendBytesCallback& send, |
| 61 const net::test_server::SendCompleteCallback& done) override { | |
| 62 send.Run(headers_ + "\r\n" + contents_, done); | |
| 61 } | 63 } |
| 62 | 64 |
| 63 void AddHeader(const std::string& key_value_pair) { | 65 void AddHeader(const std::string& key_value_pair) { |
| 64 headers_.append(base::StringPrintf("%s\r\n", key_value_pair.c_str())); | 66 headers_.append(base::StringPrintf("%s\r\n", key_value_pair.c_str())); |
| 65 } | 67 } |
| 66 | 68 |
| 67 private: | 69 private: |
| 68 std::string headers_; | 70 std::string headers_; |
| 69 std::string contents_; | 71 std::string contents_; |
| 70 | 72 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 #else | 335 #else |
| 334 return JNI_FALSE; | 336 return JNI_FALSE; |
| 335 #endif | 337 #endif |
| 336 } | 338 } |
| 337 | 339 |
| 338 bool RegisterNativeTestServer(JNIEnv* env) { | 340 bool RegisterNativeTestServer(JNIEnv* env) { |
| 339 return RegisterNativesImpl(env); | 341 return RegisterNativesImpl(env); |
| 340 } | 342 } |
| 341 | 343 |
| 342 } // namespace cronet | 344 } // namespace cronet |
| OLD | NEW |