| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 server_url_ = base::StringPrintf("http://127.0.0.1:%d", address.port()); | 63 server_url_ = base::StringPrintf("http://127.0.0.1:%d", address.port()); |
| 64 event->Signal(); | 64 event->Signal(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void DestroyServerOnIO(base::WaitableEvent* event) { | 67 void DestroyServerOnIO(base::WaitableEvent* event) { |
| 68 server_.reset(NULL); | 68 server_.reset(NULL); |
| 69 event->Signal(); | 69 event->Signal(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Overridden from net::HttpServer::Delegate: | 72 // Overridden from net::HttpServer::Delegate: |
| 73 virtual void OnConnect(int connection_id) OVERRIDE {} |
| 74 |
| 73 virtual void OnHttpRequest(int connection_id, | 75 virtual void OnHttpRequest(int connection_id, |
| 74 const net::HttpServerRequestInfo& info) OVERRIDE { | 76 const net::HttpServerRequestInfo& info) OVERRIDE { |
| 75 switch (response_) { | 77 switch (response_) { |
| 76 case kSendHello: | 78 case kSendHello: |
| 77 server_->Send200(connection_id, "hello", "text/plain"); | 79 server_->Send200(connection_id, "hello", "text/plain"); |
| 78 break; | 80 break; |
| 79 case kSend404: | 81 case kSend404: |
| 80 server_->Send404(connection_id); | 82 server_->Send404(connection_id); |
| 81 break; | 83 break; |
| 82 case kClose: | 84 case kClose: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 ASSERT_FALSE(FetchUrl(server_url_, context_getter_.get(), &response)); | 131 ASSERT_FALSE(FetchUrl(server_url_, context_getter_.get(), &response)); |
| 130 ASSERT_STREQ("stuff", response.c_str()); | 132 ASSERT_STREQ("stuff", response.c_str()); |
| 131 } | 133 } |
| 132 | 134 |
| 133 TEST_F(FetchUrlTest, NoServer) { | 135 TEST_F(FetchUrlTest, NoServer) { |
| 134 std::string response("stuff"); | 136 std::string response("stuff"); |
| 135 ASSERT_FALSE( | 137 ASSERT_FALSE( |
| 136 FetchUrl("http://localhost:33333", context_getter_.get(), &response)); | 138 FetchUrl("http://localhost:33333", context_getter_.get(), &response)); |
| 137 ASSERT_STREQ("stuff", response.c_str()); | 139 ASSERT_STREQ("stuff", response.c_str()); |
| 138 } | 140 } |
| OLD | NEW |