Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: chrome_frame/test/test_server_test.cc

Issue 51953002: [Net] Add a priority parameter to URLRequest's constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error from rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/win/scoped_handle.h" 12 #include "base/win/scoped_handle.h"
13 #include "chrome_frame/test/test_server.h" 13 #include "chrome_frame/test/test_server.h"
14 #include "net/base/request_priority.h"
14 #include "net/cookies/cookie_monster.h" 15 #include "net/cookies/cookie_monster.h"
15 #include "net/disk_cache/disk_cache.h" 16 #include "net/disk_cache/disk_cache.h"
16 #include "net/dns/host_resolver_proc.h" 17 #include "net/dns/host_resolver_proc.h"
17 #include "net/http/http_auth_handler_factory.h" 18 #include "net/http/http_auth_handler_factory.h"
18 #include "net/http/http_cache.h" 19 #include "net/http/http_cache.h"
19 #include "net/http/http_network_session.h" 20 #include "net/http/http_network_session.h"
20 #include "net/proxy/proxy_service.h" 21 #include "net/proxy/proxy_service.h"
21 #include "net/url_request/url_request.h" 22 #include "net/url_request/url_request.h"
22 #include "net/url_request/url_request_test_util.h" 23 #include "net/url_request/url_request_test_util.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
26 namespace net {
27 class NetworkDelegate;
28 } // namespace net
29
25 class TestServerTest: public testing::Test { 30 class TestServerTest: public testing::Test {
26 protected: 31 protected:
27 virtual void SetUp() { 32 virtual void SetUp() {
28 PathService::Get(base::DIR_SOURCE_ROOT, &source_path_); 33 PathService::Get(base::DIR_SOURCE_ROOT, &source_path_);
29 source_path_ = source_path_.Append(FILE_PATH_LITERAL("chrome_frame")); 34 source_path_ = source_path_.Append(FILE_PATH_LITERAL("chrome_frame"));
30 } 35 }
31 virtual void TearDown() { 36 virtual void TearDown() {
32 } 37 }
33 38
34 public: 39 public:
(...skipping 22 matching lines...) Expand all
57 return h_; 62 return h_;
58 } 63 }
59 64
60 protected: 65 protected:
61 HINTERNET h_; 66 HINTERNET h_;
62 }; 67 };
63 68
64 class TestURLRequest : public net::URLRequest { 69 class TestURLRequest : public net::URLRequest {
65 public: 70 public:
66 TestURLRequest(const GURL& url, 71 TestURLRequest(const GURL& url,
72 net::RequestPriority priority,
67 Delegate* delegate, 73 Delegate* delegate,
68 net::TestURLRequestContext* context) 74 const net::TestURLRequestContext* context,
69 : net::URLRequest(url, delegate, context) { 75 net::NetworkDelegate* network_delegate)
70 } 76 : net::URLRequest(url, priority, delegate, context, network_delegate) {}
71 }; 77 };
72 78
73 class UrlTaskChain { 79 class UrlTaskChain {
74 public: 80 public:
75 UrlTaskChain(const std::string& url, UrlTaskChain* next) 81 UrlTaskChain(const std::string& url, UrlTaskChain* next)
76 : url_(url), next_(next) { 82 : url_(url), next_(next) {
77 } 83 }
78 84
79 void Run() { 85 void Run() {
80 EXPECT_EQ(0, delegate_.response_started_count()); 86 EXPECT_EQ(0, delegate_.response_started_count());
81 87
82 base::MessageLoopForIO loop; 88 base::MessageLoopForIO loop;
83 89
84 net::TestURLRequestContext context; 90 net::TestURLRequestContext context;
85 TestURLRequest r(GURL(url_), &delegate_, &context); 91 TestURLRequest r(
92 GURL(url_), net::DEFAULT_PRIORITY, &delegate_, &context, NULL);
86 r.Start(); 93 r.Start();
87 EXPECT_TRUE(r.is_pending()); 94 EXPECT_TRUE(r.is_pending());
88 95
89 base::MessageLoop::current()->Run(); 96 base::MessageLoop::current()->Run();
90 97
91 EXPECT_EQ(1, delegate_.response_started_count()); 98 EXPECT_EQ(1, delegate_.response_started_count());
92 EXPECT_FALSE(delegate_.received_data_before_response()); 99 EXPECT_FALSE(delegate_.received_data_before_response());
93 EXPECT_NE(0, delegate_.bytes_received()); 100 EXPECT_NE(0, delegate_.bytes_received());
94 } 101 }
95 102
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 EXPECT_EQ(file.accessed(), 1); 194 EXPECT_EQ(file.accessed(), 1);
188 EXPECT_EQ(redir.accessed(), 1); 195 EXPECT_EQ(redir.accessed(), 1);
189 196
190 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos); 197 EXPECT_TRUE(person_task.response().find("Guthrie") != std::string::npos);
191 EXPECT_TRUE(file_task.response().find("function") != std::string::npos); 198 EXPECT_TRUE(file_task.response().find("function") != std::string::npos);
192 EXPECT_TRUE(redir_task.response().find("Destination") != std::string::npos); 199 EXPECT_TRUE(redir_task.response().find("Destination") != std::string::npos);
193 } else { 200 } else {
194 ::TerminateThread(worker, ~0); 201 ::TerminateThread(worker, ~0);
195 } 202 }
196 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698