| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 : binding_(this, request.Pass()), port_(port) { | 35 : binding_(this, request.Pass()), port_(port) { |
| 36 } | 36 } |
| 37 ~GetHandler() override {} | 37 ~GetHandler() override {} |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 // http_server::HttpHandler: | 40 // http_server::HttpHandler: |
| 41 void HandleRequest( | 41 void HandleRequest( |
| 42 http_server::HttpRequestPtr request, | 42 http_server::HttpRequestPtr request, |
| 43 const Callback<void(http_server::HttpResponsePtr)>& callback) override { | 43 const Callback<void(http_server::HttpResponsePtr)>& callback) override { |
| 44 http_server::HttpResponsePtr response; | 44 http_server::HttpResponsePtr response; |
| 45 if (base::StartsWithASCII(request->relative_url, "/app", true)) { | 45 if (base::StartsWith(request->relative_url, "/app", |
| 46 base::CompareCase::SENSITIVE)) { |
| 46 response = http_server::CreateHttpResponse( | 47 response = http_server::CreateHttpResponse( |
| 47 200, std::string(kPingable.data, kPingable.size)); | 48 200, std::string(kPingable.data, kPingable.size)); |
| 48 response->content_type = "application/octet-stream"; | 49 response->content_type = "application/octet-stream"; |
| 49 } else if (request->relative_url == "/redirect") { | 50 } else if (request->relative_url == "/redirect") { |
| 50 response = http_server::HttpResponse::New(); | 51 response = http_server::HttpResponse::New(); |
| 51 response->status_code = 302; | 52 response->status_code = 302; |
| 52 response->custom_headers.insert("Location", GetURL(port_, "app")); | 53 response->custom_headers.insert("Location", GetURL(port_, "app")); |
| 53 } else { | 54 } else { |
| 54 NOTREACHED(); | 55 NOTREACHED(); |
| 55 } | 56 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); | 190 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); |
| 190 EXPECT_EQ("hello", message); | 191 EXPECT_EQ("hello", message); |
| 191 base::MessageLoop::current()->Quit(); | 192 base::MessageLoop::current()->Quit(); |
| 192 }; | 193 }; |
| 193 pingable->Ping("hello", callback); | 194 pingable->Ping("hello", callback); |
| 194 base::RunLoop().Run(); | 195 base::RunLoop().Run(); |
| 195 } | 196 } |
| 196 | 197 |
| 197 } // namespace | 198 } // namespace |
| 198 } // namespace mojo | 199 } // namespace mojo |
| OLD | NEW |