| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <wininet.h> | 6 #include <wininet.h> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 test_server::FileResponse file("/file", source_path().Append( | 140 test_server::FileResponse file("/file", source_path().Append( |
| 141 FILE_PATH_LITERAL("CFInstance.js"))); | 141 FILE_PATH_LITERAL("CFInstance.js"))); |
| 142 server.AddResponse(&file); | 142 server.AddResponse(&file); |
| 143 test_server::RedirectResponse redir("/goog", "http://www.google.com/"); | 143 test_server::RedirectResponse redir("/goog", "http://www.google.com/"); |
| 144 server.AddResponse(&redir); | 144 server.AddResponse(&redir); |
| 145 | 145 |
| 146 // We should never hit this, but it's our way to break out of the test if | 146 // We should never hit this, but it's our way to break out of the test if |
| 147 // things start hanging. | 147 // things start hanging. |
| 148 QuitMessageHit quit_msg(&loop); | 148 QuitMessageHit quit_msg(&loop); |
| 149 loop.PostDelayedTask(FROM_HERE, base::Bind(QuitMessageLoop, &quit_msg), | 149 loop.PostDelayedTask(FROM_HERE, base::Bind(QuitMessageLoop, &quit_msg), |
| 150 10 * 1000); | 150 base::TimeDelta::FromSeconds(10)); |
| 151 | 151 |
| 152 UrlTaskChain quit_task("http://localhost:1337/quit", NULL); | 152 UrlTaskChain quit_task("http://localhost:1337/quit", NULL); |
| 153 UrlTaskChain fnf_task("http://localhost:1337/404", &quit_task); | 153 UrlTaskChain fnf_task("http://localhost:1337/404", &quit_task); |
| 154 UrlTaskChain person_task("http://localhost:1337/person", &fnf_task); | 154 UrlTaskChain person_task("http://localhost:1337/person", &fnf_task); |
| 155 UrlTaskChain file_task("http://localhost:1337/file", &person_task); | 155 UrlTaskChain file_task("http://localhost:1337/file", &person_task); |
| 156 UrlTaskChain goog_task("http://localhost:1337/goog", &file_task); | 156 UrlTaskChain goog_task("http://localhost:1337/goog", &file_task); |
| 157 | 157 |
| 158 DWORD tid = 0; | 158 DWORD tid = 0; |
| 159 base::win::ScopedHandle worker(::CreateThread( | 159 base::win::ScopedHandle worker(::CreateThread( |
| 160 NULL, 0, FetchUrl, &goog_task, 0, &tid)); | 160 NULL, 0, FetchUrl, &goog_task, 0, &tid)); |
| 161 loop.MessageLoop::Run(); | 161 loop.MessageLoop::Run(); |
| 162 | 162 |
| 163 EXPECT_FALSE(quit_msg.hit_); | 163 EXPECT_FALSE(quit_msg.hit_); |
| 164 if (!quit_msg.hit_) { | 164 if (!quit_msg.hit_) { |
| 165 EXPECT_EQ(::WaitForSingleObject(worker, 10 * 1000), WAIT_OBJECT_0); | 165 EXPECT_EQ(::WaitForSingleObject(worker, 10 * 1000), WAIT_OBJECT_0); |
| 166 | 166 |
| 167 EXPECT_EQ(person.accessed(), 1); | 167 EXPECT_EQ(person.accessed(), 1); |
| 168 EXPECT_EQ(file.accessed(), 1); | 168 EXPECT_EQ(file.accessed(), 1); |
| 169 EXPECT_EQ(redir.accessed(), 1); | 169 EXPECT_EQ(redir.accessed(), 1); |
| 170 | 170 |
| 171 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); | 171 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); |
| 172 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); | 172 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); |
| 173 EXPECT_TRUE(goog_task.response().find("<title>") != std::string::npos); | 173 EXPECT_TRUE(goog_task.response().find("<title>") != std::string::npos); |
| 174 } else { | 174 } else { |
| 175 ::TerminateThread(worker, ~0); | 175 ::TerminateThread(worker, ~0); |
| 176 } | 176 } |
| 177 } | 177 } |
| OLD | NEW |