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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 operator HINTERNET() { | 55 operator HINTERNET() { |
56 return h_; | 56 return h_; |
57 } | 57 } |
58 | 58 |
59 protected: | 59 protected: |
60 HINTERNET h_; | 60 HINTERNET h_; |
61 }; | 61 }; |
62 | 62 |
63 class TestURLRequest : public net::URLRequest { | 63 class TestURLRequest : public net::URLRequest { |
64 public: | 64 public: |
65 TestURLRequest(const GURL& url, Delegate* delegate) | 65 TestURLRequest(const GURL& url, |
66 : net::URLRequest(url, delegate) { | 66 Delegate* delegate, |
67 set_context(new TestURLRequestContext()); | 67 TestURLRequestContext* context) |
| 68 : net::URLRequest(url, delegate, context) { |
68 } | 69 } |
69 }; | 70 }; |
70 | 71 |
71 class UrlTaskChain { | 72 class UrlTaskChain { |
72 public: | 73 public: |
73 UrlTaskChain(const char* url, UrlTaskChain* next) | 74 UrlTaskChain(const char* url, UrlTaskChain* next) |
74 : url_(url), next_(next) { | 75 : url_(url), next_(next) { |
75 } | 76 } |
76 | 77 |
77 void Run() { | 78 void Run() { |
78 EXPECT_EQ(0, delegate_.response_started_count()); | 79 EXPECT_EQ(0, delegate_.response_started_count()); |
79 | 80 |
80 MessageLoopForIO loop; | 81 MessageLoopForIO loop; |
81 | 82 |
82 TestURLRequest r(GURL(url_), &delegate_); | 83 TestURLRequestContext context; |
| 84 TestURLRequest r(GURL(url_), &delegate_, &context); |
83 r.Start(); | 85 r.Start(); |
84 EXPECT_TRUE(r.is_pending()); | 86 EXPECT_TRUE(r.is_pending()); |
85 | 87 |
86 MessageLoop::current()->Run(); | 88 MessageLoop::current()->Run(); |
87 | 89 |
88 EXPECT_EQ(1, delegate_.response_started_count()); | 90 EXPECT_EQ(1, delegate_.response_started_count()); |
89 EXPECT_FALSE(delegate_.received_data_before_response()); | 91 EXPECT_FALSE(delegate_.received_data_before_response()); |
90 EXPECT_NE(0, delegate_.bytes_received()); | 92 EXPECT_NE(0, delegate_.bytes_received()); |
91 } | 93 } |
92 | 94 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 EXPECT_EQ(file.accessed(), 1); | 174 EXPECT_EQ(file.accessed(), 1); |
173 EXPECT_EQ(redir.accessed(), 1); | 175 EXPECT_EQ(redir.accessed(), 1); |
174 | 176 |
175 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); | 177 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); |
176 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); | 178 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); |
177 EXPECT_TRUE(redir_task.response().find("Destination") != std::string::npos); | 179 EXPECT_TRUE(redir_task.response().find("Destination") != std::string::npos); |
178 } else { | 180 } else { |
179 ::TerminateThread(worker, ~0); | 181 ::TerminateThread(worker, ~0); |
180 } | 182 } |
181 } | 183 } |
OLD | NEW |