| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 HINTERNET h_; | 61 HINTERNET h_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 class TestURLRequest : public net::URLRequest { | 64 class TestURLRequest : public net::URLRequest { |
| 65 public: | 65 public: |
| 66 TestURLRequest(const GURL& url, | 66 TestURLRequest(const GURL& url, |
| 67 Delegate* delegate, | 67 Delegate* delegate, |
| 68 TestURLRequestContext* context) | 68 net::TestURLRequestContext* context) |
| 69 : net::URLRequest(url, delegate, context) { | 69 : net::URLRequest(url, delegate, context) { |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class UrlTaskChain { | 73 class UrlTaskChain { |
| 74 public: | 74 public: |
| 75 UrlTaskChain(const std::string& url, UrlTaskChain* next) | 75 UrlTaskChain(const std::string& url, UrlTaskChain* next) |
| 76 : url_(url), next_(next) { | 76 : url_(url), next_(next) { |
| 77 } | 77 } |
| 78 | 78 |
| 79 void Run() { | 79 void Run() { |
| 80 EXPECT_EQ(0, delegate_.response_started_count()); | 80 EXPECT_EQ(0, delegate_.response_started_count()); |
| 81 | 81 |
| 82 MessageLoopForIO loop; | 82 MessageLoopForIO loop; |
| 83 | 83 |
| 84 TestURLRequestContext context; | 84 net::TestURLRequestContext context; |
| 85 TestURLRequest r(GURL(url_), &delegate_, &context); | 85 TestURLRequest r(GURL(url_), &delegate_, &context); |
| 86 r.Start(); | 86 r.Start(); |
| 87 EXPECT_TRUE(r.is_pending()); | 87 EXPECT_TRUE(r.is_pending()); |
| 88 | 88 |
| 89 MessageLoop::current()->Run(); | 89 MessageLoop::current()->Run(); |
| 90 | 90 |
| 91 EXPECT_EQ(1, delegate_.response_started_count()); | 91 EXPECT_EQ(1, delegate_.response_started_count()); |
| 92 EXPECT_FALSE(delegate_.received_data_before_response()); | 92 EXPECT_FALSE(delegate_.received_data_before_response()); |
| 93 EXPECT_NE(0, delegate_.bytes_received()); | 93 EXPECT_NE(0, delegate_.bytes_received()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 UrlTaskChain* next() const { | 96 UrlTaskChain* next() const { |
| 97 return next_; | 97 return next_; |
| 98 } | 98 } |
| 99 | 99 |
| 100 const std::string& response() const { | 100 const std::string& response() const { |
| 101 return delegate_.data_received(); | 101 return delegate_.data_received(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 protected: | 104 protected: |
| 105 std::string url_; | 105 std::string url_; |
| 106 TestDelegate delegate_; | 106 net::TestDelegate delegate_; |
| 107 UrlTaskChain* next_; | 107 UrlTaskChain* next_; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 DWORD WINAPI FetchUrl(void* param) { | 110 DWORD WINAPI FetchUrl(void* param) { |
| 111 UrlTaskChain* task = reinterpret_cast<UrlTaskChain*>(param); | 111 UrlTaskChain* task = reinterpret_cast<UrlTaskChain*>(param); |
| 112 while (task != NULL) { | 112 while (task != NULL) { |
| 113 task->Run(); | 113 task->Run(); |
| 114 task = task->next(); | 114 task = task->next(); |
| 115 } | 115 } |
| 116 | 116 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 EXPECT_EQ(file.accessed(), 1); | 187 EXPECT_EQ(file.accessed(), 1); |
| 188 EXPECT_EQ(redir.accessed(), 1); | 188 EXPECT_EQ(redir.accessed(), 1); |
| 189 | 189 |
| 190 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); | 190 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); |
| 191 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); | 191 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); |
| 192 EXPECT_TRUE(redir_task.response().find("Destination") != std::string::npos); | 192 EXPECT_TRUE(redir_task.response().find("Destination") != std::string::npos); |
| 193 } else { | 193 } else { |
| 194 ::TerminateThread(worker, ~0); | 194 ::TerminateThread(worker, ~0); |
| 195 } | 195 } |
| 196 } | 196 } |
| OLD | NEW |