OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "chrome/browser/renderer_host/renderer_security_policy.h" | 10 #include "chrome/browser/child_process_security_policy.h" |
11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
12 #include "chrome/common/chrome_plugin_lib.h" | 12 #include "chrome/common/chrome_plugin_lib.h" |
13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
15 #include "net/url_request/url_request_job.h" | 15 #include "net/url_request/url_request_job.h" |
16 #include "net/url_request/url_request_test_job.h" | 16 #include "net/url_request/url_request_test_job.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "webkit/glue/webappcachecontext.h" | 18 #include "webkit/glue/webappcachecontext.h" |
19 | 19 |
20 static int RequestIDForMessage(const IPC::Message& msg) { | 20 static int RequestIDForMessage(const IPC::Message& msg) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 uint32 request_id, | 105 uint32 request_id, |
106 const ViewHostMsg_Resource_Request& request_data) { | 106 const ViewHostMsg_Resource_Request& request_data) { |
107 return NULL; | 107 return NULL; |
108 } | 108 } |
109 | 109 |
110 virtual int GetProcessId() const { return pid_; } | 110 virtual int GetProcessId() const { return pid_; } |
111 | 111 |
112 protected: | 112 protected: |
113 // testing::Test | 113 // testing::Test |
114 virtual void SetUp() { | 114 virtual void SetUp() { |
115 RendererSecurityPolicy::GetInstance()->Add(0); | 115 ChildProcessSecurityPolicy::GetInstance()->Add(0); |
116 URLRequest::RegisterProtocolFactory("test", &URLRequestTestJob::Factory); | 116 URLRequest::RegisterProtocolFactory("test", &URLRequestTestJob::Factory); |
117 EnsureTestSchemeIsAllowed(); | 117 EnsureTestSchemeIsAllowed(); |
118 } | 118 } |
119 virtual void TearDown() { | 119 virtual void TearDown() { |
120 URLRequest::RegisterProtocolFactory("test", NULL); | 120 URLRequest::RegisterProtocolFactory("test", NULL); |
121 RendererSecurityPolicy::GetInstance()->Remove(0); | 121 ChildProcessSecurityPolicy::GetInstance()->Remove(0); |
122 | 122 |
123 // The plugin lib is automatically loaded during these test | 123 // The plugin lib is automatically loaded during these test |
124 // and we want a clean environment for other tests. | 124 // and we want a clean environment for other tests. |
125 ChromePluginLib::UnloadAllPlugins(); | 125 ChromePluginLib::UnloadAllPlugins(); |
126 | 126 |
127 // Flush the message loop to make Purify happy. | 127 // Flush the message loop to make Purify happy. |
128 message_loop_.RunAllPending(); | 128 message_loop_.RunAllPending(); |
129 } | 129 } |
130 | 130 |
131 void MakeTestRequest(int render_process_id, | 131 void MakeTestRequest(int render_process_id, |
132 int render_view_id, | 132 int render_view_id, |
133 int request_id, | 133 int request_id, |
134 const GURL& url); | 134 const GURL& url); |
135 void MakeTestRequest(ResourceDispatcherHost::Receiver* receiver, | 135 void MakeTestRequest(ResourceDispatcherHost::Receiver* receiver, |
136 int render_process_id, | 136 int render_process_id, |
137 int render_view_id, | 137 int render_view_id, |
138 int request_id, | 138 int request_id, |
139 const GURL& url); | 139 const GURL& url); |
140 void MakeCancelRequest(int request_id); | 140 void MakeCancelRequest(int request_id); |
141 | 141 |
142 void EnsureTestSchemeIsAllowed() { | 142 void EnsureTestSchemeIsAllowed() { |
143 static bool have_white_listed_test_scheme = false; | 143 static bool have_white_listed_test_scheme = false; |
144 | 144 |
145 if (!have_white_listed_test_scheme) { | 145 if (!have_white_listed_test_scheme) { |
146 RendererSecurityPolicy::GetInstance()->RegisterWebSafeScheme("test"); | 146 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme("test"); |
147 have_white_listed_test_scheme = true; | 147 have_white_listed_test_scheme = true; |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 MessageLoopForIO message_loop_; | 151 MessageLoopForIO message_loop_; |
152 ResourceDispatcherHost host_; | 152 ResourceDispatcherHost host_; |
153 ResourceIPCAccumulator accum_; | 153 ResourceIPCAccumulator accum_; |
154 int pid_; | 154 int pid_; |
155 }; | 155 }; |
156 | 156 |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); | 645 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); |
646 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.os_error()); | 646 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.os_error()); |
647 } | 647 } |
648 | 648 |
649 // The final 2 requests should have succeeded. | 649 // The final 2 requests should have succeeded. |
650 CheckSuccessfulRequest(msgs[kMaxRequests + 2], | 650 CheckSuccessfulRequest(msgs[kMaxRequests + 2], |
651 URLRequestTestJob::test_data_2()); | 651 URLRequestTestJob::test_data_2()); |
652 CheckSuccessfulRequest(msgs[kMaxRequests + 3], | 652 CheckSuccessfulRequest(msgs[kMaxRequests + 3], |
653 URLRequestTestJob::test_data_2()); | 653 URLRequestTestJob::test_data_2()); |
654 } | 654 } |
OLD | NEW |