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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc

Issue 306032: Simplify threading in browser thread by making only ChromeThread deal with di... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: a few more simplifications Created 11 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) 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/child_process_security_policy.h" 10 #include "chrome/browser/child_process_security_policy.h"
11 #include "chrome/browser/chrome_thread.h"
11 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 12 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
12 #include "chrome/common/chrome_plugin_lib.h" 13 #include "chrome/common/chrome_plugin_lib.h"
13 #include "chrome/common/render_messages.h" 14 #include "chrome/common/render_messages.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 #include "net/http/http_util.h" 16 #include "net/http/http_util.h"
16 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
17 #include "net/url_request/url_request_job.h" 18 #include "net/url_request/url_request_job.h"
18 #include "net/url_request/url_request_test_job.h" 19 #include "net/url_request/url_request_test_job.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "webkit/appcache/appcache_interfaces.h" 21 #include "webkit/appcache/appcache_interfaces.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 private: 138 private:
138 ResourceDispatcherHost::Receiver* dest_; 139 ResourceDispatcherHost::Receiver* dest_;
139 140
140 DISALLOW_COPY_AND_ASSIGN(ForwardingReceiver); 141 DISALLOW_COPY_AND_ASSIGN(ForwardingReceiver);
141 }; 142 };
142 143
143 class ResourceDispatcherHostTest : public testing::Test, 144 class ResourceDispatcherHostTest : public testing::Test,
144 public ResourceDispatcherHost::Receiver { 145 public ResourceDispatcherHost::Receiver {
145 public: 146 public:
146 ResourceDispatcherHostTest() 147 ResourceDispatcherHostTest()
147 : Receiver(ChildProcessInfo::RENDER_PROCESS, -1), host_(NULL), 148 : Receiver(ChildProcessInfo::RENDER_PROCESS, -1),
149 io_thread_(ChromeThread::IO, &message_loop_),
150 host_(NULL),
148 old_factory_(NULL) { 151 old_factory_(NULL) {
149 set_handle(base::GetCurrentProcessHandle()); 152 set_handle(base::GetCurrentProcessHandle());
150 } 153 }
151 // ResourceDispatcherHost::Receiver implementation 154 // ResourceDispatcherHost::Receiver implementation
152 virtual bool Send(IPC::Message* msg) { 155 virtual bool Send(IPC::Message* msg) {
153 accum_.AddMessage(*msg); 156 accum_.AddMessage(*msg);
154 delete msg; 157 delete msg;
155 return true; 158 return true;
156 } 159 }
157 160
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const std::string& scheme) { 237 const std::string& scheme) {
235 if (test_fixture_->response_headers_.empty()) { 238 if (test_fixture_->response_headers_.empty()) {
236 return new URLRequestTestJob(request); 239 return new URLRequestTestJob(request);
237 } else { 240 } else {
238 return new URLRequestTestJob(request, test_fixture_->response_headers_, 241 return new URLRequestTestJob(request, test_fixture_->response_headers_,
239 test_fixture_->response_data_, false); 242 test_fixture_->response_data_, false);
240 } 243 }
241 } 244 }
242 245
243 MessageLoopForIO message_loop_; 246 MessageLoopForIO message_loop_;
247 ChromeThread io_thread_;
244 ResourceDispatcherHost host_; 248 ResourceDispatcherHost host_;
245 ResourceIPCAccumulator accum_; 249 ResourceIPCAccumulator accum_;
246 std::string response_headers_; 250 std::string response_headers_;
247 std::string response_data_; 251 std::string response_data_;
248 std::string scheme_; 252 std::string scheme_;
249 URLRequest::ProtocolFactory* old_factory_; 253 URLRequest::ProtocolFactory* old_factory_;
250 static ResourceDispatcherHostTest* test_fixture_; 254 static ResourceDispatcherHostTest* test_fixture_;
251 }; 255 };
252 // Static. 256 // Static.
253 ResourceDispatcherHostTest* ResourceDispatcherHostTest::test_fixture_ = NULL; 257 ResourceDispatcherHostTest* ResourceDispatcherHostTest::test_fixture_ = NULL;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 870
867 // Sorts out all the messages we saw by request. 871 // Sorts out all the messages we saw by request.
868 ResourceIPCAccumulator::ClassifiedMessages msgs; 872 ResourceIPCAccumulator::ClassifiedMessages msgs;
869 accum_.GetClassifiedMessages(&msgs); 873 accum_.GetClassifiedMessages(&msgs);
870 ASSERT_EQ(1U, msgs.size()); 874 ASSERT_EQ(1U, msgs.size());
871 875
872 ResourceResponseHead response_head; 876 ResourceResponseHead response_head;
873 GetResponseHead(msgs[0], &response_head); 877 GetResponseHead(msgs[0], &response_head);
874 ASSERT_EQ("text/plain", response_head.mime_type); 878 ASSERT_EQ("text/plain", response_head.mime_type);
875 } 879 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698