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 (StartsWithASCII(request->relative_url, "/app", true)) { | 45 if (base::StartsWithASCII(request->relative_url, "/app", true)) { |
46 response = http_server::CreateHttpResponse( | 46 response = http_server::CreateHttpResponse( |
47 200, std::string(kPingable.data, kPingable.size)); | 47 200, std::string(kPingable.data, kPingable.size)); |
48 response->content_type = "application/octet-stream"; | 48 response->content_type = "application/octet-stream"; |
49 } else if (request->relative_url == "/redirect") { | 49 } else if (request->relative_url == "/redirect") { |
50 response = http_server::HttpResponse::New(); | 50 response = http_server::HttpResponse::New(); |
51 response->status_code = 302; | 51 response->status_code = 302; |
52 response->custom_headers.insert("Location", GetURL(port_, "app")); | 52 response->custom_headers.insert("Location", GetURL(port_, "app")); |
53 } else { | 53 } else { |
54 NOTREACHED(); | 54 NOTREACHED(); |
55 } | 55 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); | 188 EXPECT_EQ(app_url.To<std::string>() + "?foo", connection_url); |
189 EXPECT_EQ("hello", message); | 189 EXPECT_EQ("hello", message); |
190 base::MessageLoop::current()->Quit(); | 190 base::MessageLoop::current()->Quit(); |
191 }; | 191 }; |
192 pingable->Ping("hello", callback); | 192 pingable->Ping("hello", callback); |
193 base::RunLoop().Run(); | 193 base::RunLoop().Run(); |
194 } | 194 } |
195 | 195 |
196 } // namespace | 196 } // namespace |
197 } // namespace mojo | 197 } // namespace mojo |
OLD | NEW |